In C 11, 'using' can now define type aliases similar to 'typedefs':
typedef int MyInt; // Equivalent to: using MyInt = int;
While 'using' was initially introduced to support template typedefs:
template< class T > using MyType = AnotherType< T, MyAllocatorType >;
this raises the question of whether there are any subtle differences between 'typedef' and 'using' when handling non-template types.
Aliasing Behavior and Implications
Both 'typedef' and 'using' create an alias or new name for an existing type, rather than defining a new type. This means that conversions between the alias and the original type are implicit.
Therefore, there is no difference between 'typedef' and 'using' in terms of their aliasing behavior. Both constructs create weak aliases that reference the same underlying type.
The above is the detailed content of Can `using` Completely Replace `typedef` in C 11 for Non-Template Types?. For more information, please follow other related articles on the PHP Chinese website!