0

i am getting the below error when i try to compile the following code below. please suggest a good fix for the issue'.

./DataSecurity.h:60: error: template argument 1 is invalid ./DataSecurity.h:60: error: template argument 2 is invalid ./DataSecurity.h:60: error: expected unqualified-id before â>â token.

template<typename E, typename C = std::basic_string<E> >
struct CDsTableRec {
  typedef C CStr;
  typedef Ids::Type::CCountedPointer<CDsTableRec> CPtr;

  CStr    m_table;
  CStr    m_alias;
  CStr    m_prefix;
  CDsTableRec(const CStr& t, const CStr& a, const CStr& p) : m_table(t),       m_alias(a), m_prefix(p) {}
  CDsTableRec(const CStr& t) : m_table(t) {}
  CDsTableRec() {}

  CStr str() const {
    return m_prefix + (m_alias.size() ? m_alias : m_table);
  }
};

typedef std::deque<CDsTableRec::CPtr> > CTableList; --- this line gives error

CCountedPointer is also a template

Ids and Type are namespaces

Mihriban Minaz
  • 3,043
  • 2
  • 32
  • 52

1 Answers1

1
  1. CDsTableRec is a template, you need to provide a template argument to it.

  2. There is a > to many on that line.

  3. CDsTableRec<X>::CPtr is a dependent name so you need a typename in there as well. (See "Where and why do I have to put the “template” and “typename” keywords?")

So a complete and possibly working declaration would look something like

typedef std::deque<typename CDsTableRec<X>::CPtr> CTableList;

Where X is e.g. int or a class/structure name or any other valid type.

If the CTableList also needs to be a template, you can't use typedef, it's not possible to create templated type-aliases using typedef. Instead you need to use the using keyword to declare a template type alias:

template<typename T>
using CTableList = std::deque<typename CDsTableRec<T>::CPtr>;

Do note that this is introduced in the C++11 standard. If you have an older compiler that doesn't support C++11 (or higher standard) then you have to rethink your design.

Community
  • 1
  • 1
Some programmer dude
  • 400,186
  • 35
  • 402
  • 621