Rule A7-1-6 (required, implementation, automated)

The typedef specifier shall not be used.

Rationale

The typedef specifier can not be easily used for defining alias templates. Also, the typedef syntax makes the code less readable. For defining aliases, as well as template aliases, it is recommended to use the using syntax instead of the typedef. Note that active issues related to the using syntax are listed below, in the “See also” section.

Example

// $Id: A7-1-6.cpp 271687 2017-03-23 08:57:35Z piotr.tanski $
#include <cstdint>
#include <type_traits>

typedef std::int32_t (*fPointer1)(std::int32_t); // Non-compliant

using fPointer2 = std::int32_t (*)(std::int32_t); // Compliant

// template<typename T>

// typedef std::int32_t (*fPointer3)(T); // Non-compliant - compilation error

template <typename T>

using fPointer3 = std::int32_t (*)(T); // Compliant

See also

C++ Core Guidelines [11]: T.43: Prefer using over typedef for defining aliases C++ Standard Core Language Active Issues, Revision 96 [18]: 1554. Access and alias templates. C++ Standard Core Language Defect Reports and Accepted Issues, Revision 96 [18]: 1558. Unused arguments in alias template specializations.