The syntax of using
is very simple: the name to be defined goes on the left hand side, and the definition goes on the right hand side. No need to scan to see where the name is.
using I = int;
using A = int[100]; // array of 100 ints
using FP = void(*)(int); // pointer to function of int returning void
using MP = void (Foo::*)(int); // pointer to member function of Foo of int returning void
Creating a type alias with using
has exactly the same effect as creating a type alias with typedef
. It is simply an alternative syntax for accomplishing the same thing.
Unlike typedef
, using
can be templated. A "template typedef" created with using
is called an alias template.