首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >为什么这个类的专门化没有使用一个被接受的概念呢?

为什么这个类的专门化没有使用一个被接受的概念呢?
EN

Stack Overflow用户
提问于 2020-11-11 12:43:51
回答 1查看 148关注 0票数 7

下面的代码尝试使用概念对类进行部分专门化,并将方法添加到专门化中,但被clang 11.0.0拒绝:

代码语言:javascript
复制
#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给出了错误消息:

代码语言:javascript
复制
<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接受,尽管这不能保证正确性。)

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-11-11 15:43:18

这绝对是一个CLANG bug。它已经归档了- #48020

票数 6
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/64780598

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档