简体   繁体   English

模板模板参数的模板专业化

[英]Template Specialization for Template Template Parameter

I created a template class with template template parameters in .h file: 我在.h文件中创建了一个带有模板模板参数的模板类:

template<typename Index=Date, typename Value=double, template<typename> 
class Container=std::vector> class FastDataSeries 

Then I try to specialize it in .cpp file so as to utilize the C++11 "extern template" feature in other file, 然后我尝试在.cpp文件中专门化它,以便在其他文件中使用C ++ 11“extern模板”功能,

    template<> class FastDataSeries <Date, double, std::vector >;
    template<> class FastDataSeries <int, double, std::vector >;

Then I got the error message as below: 然后我收到如下错误信息:

../src/timeseries/FastDataSeries.cpp:13:61: error: type/value mismatch at argument 3 in template parameter list for 'template class Container> class MarketRisk::FastDataSeries' template<> class FastDataSeries ; ../src/timeseries/FastDataSeries.cpp:13:61:错误:模板参数列表中参数3的类型/值不匹配'模板类Container>类MarketRisk :: FastDataSeries'模板<>类FastDataSeries; ^ ../src/timeseries/FastDataSeries.cpp:13:61: error: expected a template of type 'template class Container', got 'template class std::vector' ../src/timeseries/FastDataSeries.cpp:14:60: error: type/value mismatch at argument 3 in template parameter list for 'template class Container> class MarketRisk::FastDataSeries' template<> class FastDataSeries ; ^ ../src/timeseries/FastDataSeries.cpp:13:61:错误:期望一个'模板类容器'类型的模板,得到'模板类std :: vector'../src/timeseries/FastDataSeries.cpp:14 :60:错误:模板参数列表中参数3的类型/值不匹配'模板类Container>类MarketRisk :: FastDataSeries'模板<>类FastDataSeries; ^ ../src/timeseries/FastDataSeries.cpp:14:60: error: expected a template of type 'template class Container', got 'template class std::vector' make: *** [src/timeseries/FastDataSeries.o] Error 1 ^ ../src/timeseries/FastDataSeries.cpp:14:60:错误:期望一个'模板类容器'类型的模板,得到'模板类std :: vector'make:*** [src / timeseries / FastDataSeries。 o]错误1

What's the correct grammar to do this? 这样做的正确语法是什么?

template<typename>

这与std :: vector的模板不匹配。您必须提供所有模板参数。

template<class T, class Allocator = std::allocator<T> class Container

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM