I\'ve been reviewing the draft version of the C++11 standard. Specifically the section on lambdas, and I am confused as to the reasoning for not introducing polymorphic lamb
The following (your comment to my other answer above) works:
#include
#include
struct foo
{
template
void operator()(T& t)
{
++t;
}
};
int main()
{
std::vector v;
std::for_each(v.begin (),v.end(),foo());
return 0;
}
But the following does not:
#include
#include
template
struct foo
{
void operator()(T& t)
{
++t;
}
};
int main()
{
std::vector v;
std::for_each(v.begin (),v.end(),foo()); // <-- the syntax for foo here
// is kinda fictitious
return 0;
}
Probably the C++ committee saw lambdas as being more similar to the second example than the first. (Though I haven't figured out clever way to define a lambda in which this would make a difference. Anyone got any crazy ideas?)