using IntegerType1 = int;
typedef int IntegerType2;
int main()
{
IntegerType1 n1 = 1; // OK
IntegerType2 n2 = 2; // OK
}
My questions are:
What's the difference between using-style and typedef-style?
As we already have typedef-style, what's the motivation to make using-style become a C++ standard?
Answer
The "using-style" was introduced to allow templated typedefs:
template< typename T >
using int_map = std::map< int, T >;
You can not do this with typedef
. I found it strange myself that it was decided to use using
and not typedef
as the keyword for this, but I guess the committee must have found some problem with extending the typedef
syntax.
No comments:
Post a Comment