【发布时间】:2018-10-04 16:06:37
【问题描述】:
下面的代码compiles successfully同时带有clang++ 3.8.0和g++ 7.2.0(编译标志是-std=c++14 -Wall -Wextra -Werror -pedantic-errors):
struct Foo
{
constexpr operator bool() const
{
return false;
}
};
int main()
{
constexpr bool b = Foo{};
(void)b;
}
编译器的这种行为是否符合标准?请注意,将任何成员(如int i;)添加到Foo 类doesn't change anything。
【问题讨论】:
标签: c++ constructor c++14 language-lawyer constexpr