c++ - “X 不是模板”错误

标签 c++ templates gcc

我在声明模板类时遇到问题。我尝试了许多可读性差且毫无意义的组​​合。

template <class C, class M >
class BlockCipherGenerator : public KeyGenerator
{
  ...
  private:
      M < C > m_cipher;
};

template <class C, class M >
class BlockCipherGenerator : public KeyGenerator
{
  typedef typename C::value_type CIPHER;
  typedef typename M::value_type MODE;
  private:
      MODE < CIPHER > m_cipher;
};

最佳答案

它是这么说的。

您的模板参数列表显示 M is a class , not a template .

如果你说它是一个类模板then everything's fine :

template <class C, template <class C> class M>
class BlockCipherGenerator : public KeyGenerator
{
      M<C> m_cipher;
};

记住,像 std::vector 不是一个类,而是一个类模板。像 std::vector<int>是一个类(类型)。

关于c++ - “X 不是模板”错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6970219/

相关文章:

c++ - 用另一个初始化的静态变量

c++ - Clang 自动变量模板错误

c++ - 您可以使用运行时指定的变量调用编译时实例化模板函数吗?

c - gcc48(从 Homebrew 软件下载)找不到stdio.h

c++ - 在 callgrind 输出中解释 _dl_runtime_resolve_xsave'2

c++ - 如何在 C++ 中将 int 参数放入 Sigleton 构造函数

c++ - find() STL 算法...我做错了什么?

c++ - 如何组合两个具有相同代码的模板函数?

c++ - 当需要稍后再次实例化相同类型时,模板函数的过程是什么

c - 警告 : integer constant is too large for "long" type