Alias declaration with using

suggest change

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 taking int and returning void
using MP = void (Foo::*)(int);  // pointer to member function of Foo taking int and 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.

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents