Why the Committee decided not to approve templated typedef along with templated using?
template <class T>
using my_vector = std::vector<T>;
is legal.
But
template <class T>
typedef std::vector<T> my_vector<T>;
is illegal?
Upd. The question Why does C++11 not have template typedef? is NOT answering.
Quoting from the proposal Templates aliases for C++ N1489 (Emphasis Mine):
It has been suggested to (re)use the keyword
typedef— as done in the paper [4] — to introduce template aliases:template<class T> typedef std::vector<T, MyAllocator<T> > Vec;That notation has the advantage of using a keyword already known to introduce a type alias. However, it also displays several disavantages among which the confusion of using a keyword known to introduce an alias for a type-name in a context where the alias does not designate a type, but a template;
Vecis not an alias for a type, and should not be taken for atypedef-name. The nameVecis a name for the familystd::vector<., MyAllocator<.>>– where the bullet is a placeholder for a type-name. Consequently we do not propose the “typedef” syntax.[4] Herb Sutter, Typedef templates, document no. WG21/1406.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With