c++ - 如何使用来自结构的成员模板化类型别名的模板模板参数
问题描述
我正在尝试使用来自结构的成员类型别名的模板模板参数,但我找不到正确的语法:
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
解决方案
A::type
是一个模板,而不是一个类型名。
B<A::template type> b1; // OK
B<A::type> b2; // OK
推荐阅读
- android - android如何在arraylist中找到相似的字符串
- jquery - Cheerio NPM,需要一种安全的方式来帮助对具有相同类/ID/属性的项目进行分组和分离
- kendo-ui - 传递列表
到 ASP MVC 中的剑道网格 - macos - 在 sed 中插入标签
- android - 如何强制 manifest.json 在现有 Android 设备上刷新
- ruby-on-rails - Ruby:哈希:使用一个记录属性作为键,另一个作为值
- angularjs - 如何使用基于表格行的自定义消息验证 angularjs 中的空字段
- c# - .net 4.5 控制器:参数多态性和自定义 Json 反序列化
- c++ - 当我按值传递参数时对象被破坏?
- amazon-web-services - 如何防止从云端重定向到我的服务器?