AUTOSAR C++14 Rule A7-1-6
The typedef specifier shall not be used
Description
Rule Definition
The typedef specifier shall not be used.
Rationale
The using
syntax is a better alternative to
typedef
-s for defining aliases.
Since C++11, the using
syntax allows you to define template aliases
where the template arguments are not bound to a data type. For instance, the following
statements define an alias vectorType
for vector
,
where the argument T
is not bound to a data type and can be substituted
later:
template<class T, class Allocator = allocator<T>> class vector; template<class T> using vectorType = vector<T, My_allocator<T>>; vectorType<int> primes = {2,3,5,7,11,13,17,19,23,29};
typedef
keyword does not allow defining such template aliases.Polyspace Implementation
The rule checker flags all uses of the typedef
keyword.
If you do not want to remove certain instances of the typedef
keyword, add a comment justifying those results. See:
Address Results in Polyspace User Interface Through Bug Fixes or Justifications if you review results in the Polyspace user interface.
Address Results in Polyspace Access Through Bug Fixes or Justifications (Polyspace Access) if you review results in a web browser.
Annotate Code and Hide Known or Acceptable Results if you review results in an IDE.
Troubleshooting
If you expect a rule violation but Polyspace® does not report it, see Diagnose Why Coding Standard Violations Do Not Appear as Expected.
Examples
Check Information
Group: Declaration |
Category: Required, Automated |
Version History
Introduced in R2019a