我如何将现有模板类部分分为新类型
How can I partially specialize a existing template class into a new type?
-----重要:这不是部分模板专业化的解决方案,而是我在不知道的情况下寻找类型的别名。对不起,混乱------
我想做的
我想专业地将BOOST :: UNOREREDED_MULTIMAP本质上只需要存储的数据,因此将密钥永久性化为boost :: uuids :: uuid。
当前尝试
template<class t>
boost::unordered_multimap<boost::uuids::uuid, t, boost::hash<boost::uuids::uuid>> unorderedUUIDMultMap;'
Here is the usage:
unorderedUUIDMultMap<int> uuidMultMap; //Should create a mutlimap storing ints.
这是错误:
main.cpp|24|error: expected ';' before 'uuidMultMap'|
我还尝试在模板之前使用" typedef",但这也没有奏效。
我如何正确执行此简单的快捷方式?
您想要的不是部分专业化,而是模板类型别名:
template <typename T> using my_mmap = boost::unordered_multimap<boost::uuids::uuid, T, boost::hash<boost::uuids::uuid>>;
相关文章:
- 如何检测类型类型别名?
- 在C++中创建新的类型特征
- 是否可以在没有结构的情况下创建新的类型变量?
- 在模板中使用类型类型的类型类型使用模板类别IT自我
- 具有枚举类型类型的C 方法
- qmetatype ::类型从模板类型类型
- 如果模板别名声明可以解决新的类型家庭
- C 线程错误:无类型类型
- C++ 类型(类型名称)上的问题
- 新的类型安全枚举是否定义为从 0 开始
- 确定类型类型
- 函数指针类型(F)(类型)和类型(类型)(类型)(类型)之间的差异
- C++:将指针设置为 nullptr 和将其初始化为新变量类型之间的区别
- C/C++中的"#define AP_MODULE_DECLARE(类型)类型"
- 哪些适用于 Windows 的 C++11 编译器支持新的类型特征,如"is_nothrow_move_constructible"?
- 为什么我们需要依赖于 C++ 中的模板参数的类型类型名
- 函数常量返回类型:类型引用的初始化无效
- 特征类型类型定义失败,并显示 C4430
- 定义一个行为类似于标准c++数据类型的新数据类型
- 为新文件类型重载 >> 运算符的优雅方法是什么?