Rule A8-2-1 (required, implementation, automated)

When declaring function templates, the trailing return type syntax shall be used if the return type depends on the type of parameters.

Rationale

Use of trailing return type syntax avoids a fully qualified return type of a function along with the typename keyword.

Example

// $Id: A8-2-1.cpp 289436 2017-10-04 10:45:23Z michal.szczepankiewicz $ #include <cstdint> template <typename T> class A { public: using Type = std::int32_t; Type F(T const&) noexcept; Type G(T const&) noexcept; }; template <typename T> typename A<T>::Type A<T>::F(T const&) noexcept // Non-compliant { // Implementation } template <typename T> auto A<T>::G(T const&) noexcept -> Type // Compliant { // Implementation }

See also

HIC++ v4.0 [9]: 7.1.7 Use a trailing return type in preference to type disambiguation using typename.