(tl;dr: using
supports templates, whereas typedef
does not.)
As it sounds like you know already, the difference between the two examples without templates is nothing:
[C++11: 7.1.3/2]:
A typedef-name can also be introduced by an alias-declaration. The identifier following the using
keyword becomes a typedef-name and the optional attribute-specifier-seq following the identifier appertains to that typedef-name. It has the same semantics as if it were introduced by the typedef
specifier. In particular, it does not define a new type and it shall not appear in the type-id.
However, template typedef
s do not exist!
[C++11: 14.5.7/1]:
A template-declaration in which the declaration is an alias-declaration (Clause 7) declares the identifier to be a alias template. An alias template is a name for a family of types. The name of the alias template is a template-name.
Why didn't they simply re-use typedef
syntax? Well, I think typedef
is simply the "old" style and, given the use of using
in other contexts, it was decided that new functionality should take the using
form for consistency.
typedef
does. – Perceptibletypedef
but used it for historical reasons; however, now that we're adding new functionality, we have an opportunity to stray." – Tompion