在下面的示例中,我有一个带有
static const
和static constexpr
成员变量的类模板。
template <class T>
struct S { // MSVC: clang:
static const bool value1 = T::value1; // error error
static constexpr bool value2 = T::value2; // error OK
};
S<void> s;
S<void>
中的成员变量有语法错误,但没有被使用。 MSVC 和 clang 不同意是否诊断错误。查看代码中的注释。 现场演示.
哪个编译器是正确的?