While defining the following lambda function
// file prog.hpp
template<typename T>
auto function = [](T& v){ return (v+= 2); }
I get the error:
error:template declaration of auto function
Please tell the correction that I should do
I am using g++-4.6.1 -std=c++0x -c prog.hpp
You can’t have templated lamdba expressions or closures. You can either make a templated traditional function, or a lambda factory (but the latter is more expensive):
Or: