【发布时间】:2020-06-02 22:21:12
【问题描述】:
我正在使用 g++ 10 学习新实现的 C++20 标准概念。
我坚持一个简单的类型要求。即我想实现模板参数T 具有T::inner 成员名称的要求。
这是我的错误代码。这个简单的代码有什么问题以及如何修复它?
#include<concepts>
template<typename T>
concept ContainsInner = requires
{
typename T::inner;
};
template<ContainsInner T>
struct S{};
struct Q
{
int inner;
};
int main()
{
S<Q> s; // instantiate S with Q for template type,
// which must satisfy the ContainsInner concept.
// Q indeed contains the inner name but still the compilation fails
}
【问题讨论】:
-
为什么投反对票?
标签: c++ c++20 c++-concepts