模板模板参数的模板专用化
Template Specialization for Template Template Parameter
>我在 .h 文件中创建了一个模板模板参数的模板类:
template<typename Index=Date, typename Value=double, template<typename>
class Container=std::vector> class FastDataSeries
然后我尝试将其专门化.cpp文件中,以便利用其他文件中的C++11"外部模板"功能,
template<> class FastDataSeries <Date, double, std::vector >;
template<> class FastDataSeries <int, double, std::vector >;
然后我收到如下错误消息:
../src/timeseries/FastDataSeries.cpp:13:61:错误:类型/值不匹配 在"模板类容器"的模板参数列表中的参数 3 处>类 市场风险::快速数据系列的模板<>类快速数据系列; ^ ../src/timeseries/FastDataSeries.cpp:13:61:错误:预期为 类型为"模板类容器"的模板,得到 '模板类 std::vector' ../src/timeseries/FastDataSeries.cpp:14:60:错误:类型/值不匹配 在"模板类容器"的模板参数列表中的参数 3 处>类 市场风险::快速数据系列的模板<>类快速数据系列; ^ ../src/timeseries/FastDataSeries.cpp:14:60:错误:预期为 类型为"模板类容器"的模板,得到 '模板类 std::vector' 制作: *** [src/timeseries/FastDataSeries.o]错误 1
这样做的正确语法是什么?
template<typename>
这与 std::vector 的模板不匹配。您必须提供所有模板参数。
template<class T, class Allocator = std::allocator<T> class Container
相关文章:
- 具有常量引用参数的函数模板专用化
- 通过依赖类型使用非类型模板参数的单类型模板参数类模板的部分专用化
- 具有多个参数的模板化类专用化,其中一个模板参数是模板本身
- 具有可变参数非类型参数的模板专用化
- 类专用化,没有用作专用化模板参数的类的模板参数
- 基于枚举参数调用专用模板方法
- 检查类是否具有模板专用化(使用布尔值或 int 等模板参数)
- 专用于可变参数模板成员函数
- 如何将模板类专用化为也接受模板模板参数
- 调用模板专用化,具有更多参数的单参数模板调用的特定值
- 有没有办法根据 lambda 参数返回类型部分专用化我的模板化函数?
- C++ 将派生类的成员函数指针作为参数传递时选择了错误的模板专用化
- cpp 模板专用化,错误说参数 1 的类型为 T,这取决于参数 T
- 具有不同非类型模板参数的模板类部分专用化
- 带有void类型和参数的C++11模板专用化
- 类模板专用化演绎是否应该考虑演绎指南参数初始化?
- 使用模板模板参数进行模板定义的函数专用化
- 在模板专用化中使用非类型模板模板参数
- C++具有可变参数专用参数的模板,用于参数数量
- 具有专用参数的类方法