views:

344

answers:

5

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?

+2  A: 

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

typedef std::deque <int> IntDeque;
anon
+8  A: 

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_
Doug T.
+1  A: 

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++

dirkgently
A: 

The way you could do this is:

#define type deque

But that comes with several disadvantages.

Greg Rogers
yea, it would turn things like "typename" into "dequename" (I recognize that "type" is an example, but still it's a BIG problem). I would say avoid this at all costs.
Evan Teran
+13  A: 

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_;
Éric Malenfant