【发布时间】:2021-11-21 18:07:19
【问题描述】:
我正在尝试使用来自结构的成员类型别名的模板模板参数,但我找不到正确的语法:
struct A
{
template <typename T>
using type = int;
};
template <template <typename> class C>
struct B
{
// ...
};
B<typename A::type> b; // Does not compile: error: template argument for template template parameter must be a class template or type alias template
B<typename A::template type> b; // Does not compile: error: expected an identifier or template-id after '::'
B<typename A::template <typename> type> b; // Does not compile
B<typename A::template <typename> class type> b; // Does not compile
【问题讨论】:
-
试试
B<A::type> b; -
@JeJo 我想我可以使用不同的设计,这是已知的 c++ 限制吗?
-
@cigien 这也会导致
error: template argument for template template parameter must be a class template or type alias template -
好像ok。您使用的是什么编译器、版本和标志?
-
@cigien 我正在使用
Apple clang version 11.0.0 (clang-1100.0.33.16)虽然,如下所述B<A::template type> b正在为我工作。