小编Rom*_*biy的帖子

模板类的模板类专业化

相关问题:

请考虑以下代码:

  template <typename T>
  struct is_std_vector: std::false_type { };

  template<typename ValueType>
  struct is_std_vector<std::vector<ValueType>>: std::true_type { };
Run Code Online (Sandbox Code Playgroud)

为什么这样的模板类专业化语法是正确的?以下似乎更合乎逻辑:

  template <typename T>
  struct is_std_vector: std::false_type { };

  template<> //--- because it is is_std_vector specialization
  template<typename ValueType>
  struct is_std_vector<std::vector<ValueType>>: std::true_type { };
Run Code Online (Sandbox Code Playgroud)

c++ templates template-specialization

7
推荐指数
1
解决办法
398
查看次数

标签 统计

c++ ×1

template-specialization ×1

templates ×1