std::for_each - function template; one of the template parameters is the type of the function argument.
You cannot use a local type as an argument to a template. This is simply a limitation currently in this language. In the upcoming C ++, C ++ 0x revision, this restriction is removed, so you can use local types as template arguments.
Visual C ++ 2010 already supports the use of local classes as template arguments; Support in other compilers may vary. I assume that any compiler that supports C ++ 0x lambdas will also support the use of local classes as template arguments (this may not be entirely true, but it makes sense).
James McNellis
source share