Sven Groot wrote:
I'm not entirely sure why you're using std::find_if in the first place. It seems like all you're doing is finding a string value in the list, which regular std::find can do.
I'm obviously doing something wrong, then. Cause this:
RIter = std::find(v1.begin(), v1.end(), string("pearly") );gives this result:
error C2784: 'bool std::operator ==(const std::vector<_Ty,_Alloc> &,const std::vector<_Ty,_Alloc> &)' :
could not deduce template argument for 'const std::vector<_Ty,_Alloc> &' from 'std::basic_string<_Elem,_Traits,_Ax>'
C:\Program Files\Microsoft Visual Studio 8\VC\include\algorithm 40
Sven Groot wrote:
Using string::compare as the predicate for find_if is never going to work because it returns an int which is zero when the strings are equal rather than a boolean which is nonzero (true) when the strings are equal.
Yeah, I originally had a not1() prefixing all of that, but have left it out trying to figure out why it's failing. Well, I know why it's failing, but whether it can be resolved.
The point of this exercise is not just to solve this particular example, but to learn the appropriate 'generic' practice. It seems basic_string doesn't have all the bits needed by the algorithm and functional libs - or at least I'm doing something stupid.