相关疑难解决方法(0)

c ++使用模板类嵌套模板专业化

我的问题如下.这是我的方法:

template<class T>
T my_function();
Run Code Online (Sandbox Code Playgroud)

这些专业可行:

template<>
int my_function();   //my_function<int>();

template<>
float my_function();  //my_function<flot>();
...
Run Code Online (Sandbox Code Playgroud)

但这些不是:

1.

    template<>
    template<class T>   
    std::list<T> my_function();   //my_function<std::list<class T> >();
Run Code Online (Sandbox Code Playgroud)

2.

    template<class T>   
    template<>
    std::vector<T> my_function();   //my_function<std::vector<class T> >();
Run Code Online (Sandbox Code Playgroud)

我收到错误:

too many template-parameter-lists
Run Code Online (Sandbox Code Playgroud)

所以我的问题是: 如何使用模板类专门化模板?

c++ templates nested

5
推荐指数
1
解决办法
254
查看次数

标签 统计

c++ ×1

nested ×1

templates ×1