g++乐意接受以下代码,而clang和msvc都无法匹配出线定义。
有任何想法为什么?
template <bool B>
struct test
{
test() requires (B);
test() requires(!B);
};
template <>
test<true>::test()
{}
template <>
test<false>::test()
{}
int main()
{
test<false> a;
test<true> b;
return 0;
}
Clang:
错误: '
test
' 的定义与 'test<true>
' 中的任何声明都不匹配
Msvc:
错误 C2244: '
test<true>::test
':无法将函数定义与现有声明匹配