page 1 of 1
Comments: 5 | Views: 2061
RichardRudek
RichardRudek
So what do you expect for nothin'... :P
I was wondering whether anyone has been able to get find_if working when using a vector of string, searching for a paritcualr string.

[I've documented what I've found so far on my blog], and would be interested if any of you have found a solution - although it's just an academic one, now.

Thanks.
Sven Groot
Sven Groot
You can't have everything; after all, where would you put it?
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.

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.
Sven Groot
Sven Groot
You can't have everything; after all, where would you put it?
I think that's because you're not #including the <string> header so you're missing half of the basic_string class. <cstring> != <string>.
Sven Groot
Sven Groot
You can't have everything; after all, where would you put it?
I don't think so. The problem is that the second parameter you're trying to bind to is already a reference and the bind2nd function tries to take a reference to that, which doesn't work. Plus then there's the problem with the compare return type which I mentioned earlier.
page 1 of 1
Comments: 5 | Views: 2061