Question

I wanted to do

typedef deque type; //error, use of class template requires template argument list
type<int> container_;

But that error is preventing me. How do I do this?

Was it helpful?

Solution

You can't (until C++0x). But it could be emulated with:

template<typename T>
struct ContainerOf
{
  typedef std::deque<T> type;
};

used as:

ContainerOf<int>::type container_;

OTHER TIPS

deque is not a type. It is a template, used to generate a type when given an argument.

 deque<int> 

is a type, so you could do

 typedef deque<int> container_

You don't, C++ does not yet support this kind of typedef. You can of course say;

typedef std::deque <int> IntDeque;

You hit an error because you missed to specify int in deque.

But note that: Template typedef's are an accepted C++0x feature. Try with the latest g++

The way you could do this is:

#define type deque

But that comes with several disadvantages.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top