我可以得到以下代码进行编译:
enum E {a, b, c};
void f()
{
E e;
std::function<void()> f = [&]() { e = a; };
}
但不是以下一个:
void f()
{
enum E {a, b, c};
E e;
std::function<void()> f = [&]() { e = a; };
}
发出以下编译器错误:
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)'
该错误是可预期的还是错误?