33

I'm having trouble declaring a template class. I've tried an number of ill-readable and non-sensical combinations.

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

And

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;
};
Lightness Races in Orbit
  • 378,754
  • 76
  • 643
  • 1,055
jww
  • 97,681
  • 90
  • 411
  • 885

1 Answers1

50

It's what it says.

Your template parameter list says that M is a class, not a template.

If you say that it's a class template, then everything's fine:

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

Remember, something like std::vector is not a class, but a class template. Something like std::vector<int> is a class (type).

Lightness Races in Orbit
  • 378,754
  • 76
  • 643
  • 1,055