Reputation: 4346
In general, we can do
typedef std::vector<int> container1;
typedef std::vector<char> container2;
But it looks like we can't do something like.
typedef vector container;
container<int> ins;
Is there anyway to achieve this? What I can think of is using macro.
Upvotes: 2
Views: 3034
Reputation: 98068
#include <vector>
template<class T>
using Vec = std::vector<T>;
Vec<int> v; // same as std::vector<int> v;
And in a similar fashion, you can rewrite the typedefs in C++11, as:
using container1 = std::vector<int>;
using container2 = std::vector<char>;
These are exactly same as the typedefs in your question.
Upvotes: 11