std::for_each on a member function with 1 argument

Posted by Person on Stack Overflow See other posts from Stack Overflow or by Person
Published on 2010-04-04T02:14:01Z Indexed on 2010/04/04 2:23 UTC
Read the original article Hit count: 270

Filed under:
|
|

I'm wondering how to implement what is stated in the title. I've tried something like...

std::for_each( a.begin(), a.end(), std::mem_fun_ref( &myClass::someFunc ) )

but I get an error saying that the "term" (I"m assuming it means the 3rd argument) doesn't evaluate to a function with 1 argument, even though someFunc does take one argument - the type of the objects stored in a.

I'm wondering if what I'm trying to do is possible using the standard library (I know I can do it easily using boost).

P.S. Does using for_each and mem_fun_ref have any performance implications in comparison to just iterating through a manually and passing the object to someFunc?

© Stack Overflow or respective owner

Related posts about c++

Related posts about std