AutosarC++18_03-A13.1.2

User defined suffixes of the user defined literal operators shall start with underscore followed by one or more letters

Required inputs: IR

Rationale

Suffixes that do not begin with the underscore character are reserved for operators provided by the standard library.

Example
// $Id: A13-1-2.cpp 289436 2017-10-04 10:45:23Z michal.szczepankiewicz $
constexpr long double operator"" _m(long double meters) // Compliant
{
  // Implementation
  return meters;
}
constexpr long double operator"" _kg(long double kilograms) // Compliant
{
  // Implementation
  return kilograms;
}
constexpr long double operator"" m(long double meters) // Non-compliant
{
  // Implementation
  return meters;
}
constexpr long double
operator"" kilograms(long double kilograms) // Non-compliant
{
  // Implementation
  return kilograms;
}
void Fn() {
  long double weight = 20.0_kg;
  long double distance = 204.8_m;
}
See Also
  • none

Possible Messages

Key

Text

Severity

Disabled

leading_space

User-defined literal operator name preceded by space.

None

False

user_defined_literal_naming

User-defined literals shall be named appropriately.

None

False

Options

allow_unicode_identifiers

allow_unicode_identifiers : bool = False

Whether to allow unicode identifiers of the form (XID_start XID_continue*).
 

check_for_leading_space

check_for_leading_space : bool = False

Whether to check for and report a leading space in the operator name.
 

suffix_pattern

suffix_pattern : typing.Pattern[str] = '^_[^\W\d]+$'

Regular expression the user-defined literal suffix must match. The suffix is the part of the operator name following operator "" (e.g., _km in operator "" _km).