相关疑难解决方法(0)

使用模板专业化

通常的模板结构可以是专门的,例如,

template<typename T>
struct X{};

template<>
struct X<int>{};
Run Code Online (Sandbox Code Playgroud)

C++ 11为我们提供了using表达模板typedef 的新酷语法:

template<typename T>
using YetAnotherVector = std::vector<T>
Run Code Online (Sandbox Code Playgroud)

有没有办法使用类似于结构模板的特化的构造为这些定义模板特化?我尝试了以下方法:

template<>
using YetAnotherVector<int> = AFancyIntVector;
Run Code Online (Sandbox Code Playgroud)

但它产生了编译错误.这有可能吗?

c++ templates template-specialization c++11

6
推荐指数
1
解决办法
382
查看次数

标签 统计

c++ ×1

c++11 ×1

template-specialization ×1

templates ×1