Hrisip
Hrisip

Reputation: 920

Is there a way to have an alias of a template and preserve Class Template Argument Deduction?

#include <vector>

template<class T>
using vec = std::vector<T>;

int main()
{
    std::vector a{2,3};
    // vec b{2,3}; // not going to work
}

Are we still forced to use macros? There are so many disadvantages in using them...

Upvotes: 3

Views: 74

Answers (1)

Guillaume Racicot
Guillaume Racicot

Reputation: 41800

This is a known problem with CTAD that has been fixed in C++20

Are we still forced to use macros?

No. I'd recommend using std::vector if you want CTAD

Upvotes: 4

Related Questions