下面的代码尝试使用概念对类进行部分专门化,并将方法添加到专门化中,但被clang 11.0.0拒绝:
#include <concepts>
template <typename T> // note: previous template declaration is here
struct S {};
template <std::integral T>
struct S<T>
{
void f();
};
template <std::integral T> // error: type constraint differs in template redeclaration
void S<T>::f()
{
}clang给出了错误消息:
<source>:14:16: error: type constraint differs in template redeclaration
template <std::integral T>
^
<source>:3:11: note: previous template declaration is here
template <typename T>(请参阅https://godbolt.org/z/Wv1ojK)。为什么这段代码是错误的?或者这是clang中的一个bug?(FWIW,此代码被gcc主干和MSVC 19.28接受,尽管这不能保证正确性。)
发布于 2020-11-11 15:43:18
这绝对是一个CLANG bug。它已经归档了- #48020。
https://stackoverflow.com/questions/64780598
复制相似问题