rh0x
rh0x

Reputation: 1463

C++ - Template + 'using' clause - mismatch argument error

I'm trying to use a template and two typedef, but I know that the only way is to insert a 'using' clause like that:

template<typename T>
using Car = std::pair<T, T>;
using SparseMatrix = std::vector< Car >;

The problem is that gcc gives me the following error:

error: type/value mismatch at argument 1 in template parameter list for ‘template<class _Tp, class _Alloc> class std::vector’

I think the problem is that Car is not a type because of the 'using' clause. How can I resolve?

Upvotes: 0

Views: 201

Answers (1)

TartanLlama
TartanLlama

Reputation: 65620

Car is an alias template, so you need to take a template argument in SparseMatrix and forward it on:

template <typename T>
using SparseMatrix = std::vector<Car<T>>;

Upvotes: 4

Related Questions