【发布时间】:2021-05-13 06:47:42
【问题描述】:
#include <type_traits>
int main()
{
auto f = [] {};
static_assert(std::is_same_v<decltype(!f), bool>); // ok
f.operator bool(); // error: ‘struct main()::<lambda()>’
// has no member named ‘operator bool’
}
C++ 是否保证 lambda 未命名类始终定义了 operator bool()?
【问题讨论】:
标签: c++ lambda operator-overloading c++14 standards