#include <functional>
struct T {
explicit operator bool() { return true; }
};
int main() {
T t;
if(t) {} // OK
auto l = [&]() {
if (t) {} // Error
};
}
Run Code Online (Sandbox Code Playgroud)
MSVC的行为在这里看起来奇怪不一致; OK行和Error行之间的唯一区别是一个是lambda.这是一个错误吗?