作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
以下代码尝试使用概念对类进行部分特化并向特化添加方法,但被 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中的一个错误? (FWIW,此代码被 gcc trunk 和 MSVC 19.28 接受,尽管这不能保证正确性。)
最佳答案
这绝对是一个 CLANG 错误。已经备案 - #48020 .
关于c++ - 为什么不接受使用概念的此类特化?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64780598/
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 我们不允许提问寻求书籍、工具、软件库等的推荐。您可以编辑问题,以便用事实和引用来回答。 关闭 4 年前。
正如您在 this travis.yml 中看到的那样文件,我的代码依赖于一些第三方库,我在构建项目之前将它们安装在远程系统上。 Travis 每次推送提交时都会下载并构建这些库,这可以避免吗?我的意
我是一名优秀的程序员,十分优秀!