为什么不接受使用概念的这种课程专业化?
Why isn't this class specialization using a concept accepted?
以下代码试图使用概念部分专门化一个类,并在专门化中添加一个方法,但被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)。为什么这个代码是错误的?或者这是叮当声中的一只虫子?(FWIW,这个代码被gcc trunk和MSVC 19.28接受,尽管这不能保证正确性。(
这绝对是一个CLANG错误。它已经被归档了——#48020。
相关文章:
- 为什么线程不接受此输入?
- 函数不接受 X 参数,函数使用默认参数
- C++ boost::asio::ip::tcp::acceptor 有时不接受连接器?
- "专业化不参与超载"
- B不接受8作为输入的是什么?C++
- C++数组输入不接受一定数量的整数
- C++概念assignable_from不接受 const&-return 运算符=
- 斯堪夫不接受输入
- C++字符数组不接受超过 4 个字符的输入
- CIN不接受C++中带有空格的输入?
- 为什么C++ STL 哈希表 (unordered_map) 不接受向量作为键
- 为什么不接受具有默认分配参数的函数作为 0-arg 生成器?
- 模板接受常量,但不接受文字
- 如何在构造函数中传递 const 引用时强制编译器不接受右值
- 为什么 strtok_r() 只接受字符数组而不接受字符指针
- C++ cout 不接受字符串或带 + 的字符串
- std::cin不接受输入
- 带有openSSL的libwebsocket服务器不接受连接
- 函数不接受 C++ 参数
- 将任意数据传递给不接受"void* userarg"的C++回调