find + lambda, how to write the lambda argument

1
2
3
4
5
6
7
8
typedef vector<AJ_Component*> v_children;
typedef v_children::iterator item_it;

v_children items;

item_it it = find(items.begin(), items.end(), [](AJ_Component* c) {// <---it doesn't compile
	return true;
});


I've also tried
1
2
3
find(items.begin(), items.end(), [h](AJ_Component* c) -> bool {
    	return true;
}
That there isn't C++. You are misunderstanding something important.

Look here for an example of how to make yourself a proper predicate.
http://www.cplusplus.com/reference/algorithm/find_if/

Hope this helps.
closed account (1yR4jE8b)
What compiler are you using? Did you enable the C++0x extensions?
what I mean is find_if, Thanks for the comment and the link.

I'm using vs2010 that support the c++0x, got it work with find_if :)
Last edited on
Topic archived. No new replies allowed.