Reputation:
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?
Upvotes: 3
Views: 2600
Reputation: 14148
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_;
Upvotes: 16
Reputation: 36429
The way you could do this is:
#define type deque
But that comes with several disadvantages.
Upvotes: 0
Reputation: 111130
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++
Upvotes: 1
Reputation: 65599
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_
Upvotes: 8
Reputation:
You don't, C++ does not yet support this kind of typedef. You can of course say;
typedef std::deque <int> IntDeque;
Upvotes: 2