I can get the following code to compile:
enum E {a, b, c}; void f() { E e; std::function<void()> f = [&]() { e = a; }; }
but not the following:
void f() { enum E {a, b, c}; E e; std::function<void()> f = [&]() { e = a; }; }
which produces the following compiler error:
1>test.cpp(5): error C2665: '`anonymous-namespace'::<lambda1>::<lambda1>' : none of the 2 overloads could convert all the argument types 1> test.cpp(5): could be '`anonymous-namespace'::<lambda1>::(f::E &,f::E &)' 1> while trying to match the argument list '(f::E, f::E)'
Is this error expected or is it an error?
source share