rspec/rules/S5416/rule.adoc
Arseniy Zaostrovnykh 7ca29f686f Force linebreaks
2021-02-02 15:02:10 +01:00

24 lines
671 B
Plaintext

Since {cpp}11, type aliases can be declared via ``++using++`` or ``++typedef++``. ``++using++`` should be preferred as more readable because you see the new name/alias first.
In addition, ``++using++`` can be templated, which makes it applicable to more situations than ``++typedef++``.
== Noncompliant Code Example
----
typedef void (*FunctionPointerType)(int);
----
== Compliant Solution
----
using FunctionPointerType = void (*)(int);
----
== See
* https://github.com/isocpp/CppCoreGuidelines/blob/036324/CppCoreGuidelines.md#t43-prefer-using-over-typedef-for-defining-aliases[{cpp} Core Guidelines - T.43] - Prefer using over typedef for defining aliases