【发布时间】:2019-11-23 04:18:27
【问题描述】:
假设我有一个带有可变参数概念模板成员的可变参数概念模板类。
#include <type_traits>
template<typename T>
concept Arithmetic = std::is_arithmetic_v<T>;
template<Arithmetic... Scalars>
class Foo
{
public:
template<Arithmetic... OtherScalars>
Foo(OtherScalars&&... args)
{
}
};
上面的代码使用GCC (trunk) 编译失败,但使用Clang (experimental concepts) 编译通过。
GCC 编译器输出
source>: In instantiation of 'class Foo<int, float, double>':
<source>:20:33: required from here
<source>:11:5: internal compiler error: in tsubst_constraint, at cp/constraint.cc:1949
11 | Foo(OtherScalars&&... args)
| ^~~
Please submit a full bug report, with preprocessed source if appropriate. See <https://gcc.gnu.org/bugs/> for instructions.
ASM generation compiler returned: 1
LIVE DEMO
这是GCC 中的错误还是我在这里做错了什么?
【问题讨论】:
-
在您的问题正文中包含编译错误消息是合适的。
-
@Wyck 好的,完成!
-
内部编译器错误肯定是编译器中的错误
-
@ÖöTiib 我相信您可以将其发布为答案
标签: c++ gcc variadic-templates c++20 c++-concepts