c++ - 如何为依赖类型扩展参数包?
问题描述
扩展参数包的语法是什么,我想要的类型直接依赖于包中的类型?
例如:
template <typename T>
struct foo
{
typedef T value_type;
};
template <typename ... T>
struct aggregate_of_foo
{
typedef std::tuple<foo<T>::value_type...> tuple; // MSVC compiler error here
};
解决方案
如果您的意思是foo
而不是bar
in your typedef
,那么您只是缺少typename
之前的关键字:
template <typename ... T>
struct aggregate_of_foo
{
using tuple_foo = std::tuple<typename foo<T>::value_type...>;
// ^^^^^^^^
};
另请注意,我将其命名为tuple_foo
因为这比拥有更有意义tuple
。
推荐阅读
- bash - 将字符串转换为 BASH 中的参数列表
- android - RelativeLayout 不会水平填充屏幕
- flutter - 如何在 Flutter 中制作圆形渐变颜色按钮 扑
- apache - 我的新版本没有在浏览器发布更新中被浏览
- javascript - 如何以角度将 JSON 数组插入对象
- bash - 如何使用 BASH_REMATCH 捕获重复模式的最长匹配
- node.js - 无法在使用 Express 和 Azure Cosmos DB 的 Angular 应用程序中配置 MongoDB
- angular - 在应用程序模块以外的单独模块中找不到角度材质数据源
- swift - 我正在尝试展示 MVC 的示例,但它没有生成任何输出
- java - ansible 在远程主机的环境变量中找不到暴露的命令