AutosarC++19_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

User-defined literal operator suffixes must follow the standard naming convention: start with an underscore followed by one or more letters. This convention prevents name conflicts with standard library literals and makes it clear that the suffix is user-defined. Arbitrary suffixes without the underscore prefix are reserved for the standard library and future use.
Bad code (invalid literal suffix):
// ERROR: suffix doesn't start with underscore
long long operator"" km(unsigned long long distance) {
    return distance * 1000;
}

// ERROR: no letters after underscore
constexpr double operator"" _(long double value) {
    return value * 3.14159;
}
Good code (valid literal suffix):
// OK: underscore followed by letters
long long operator"" _km(long long distance) {
    return distance * 1000;
}

constexpr double operator"" _rad(double deg) {
    return deg * 3.14159 / 180.0;
}

void Use() {
    auto distance = 5_km;      // Uses _km suffix
    auto angle = 180.0_rad;    // Uses _rad suffix
}

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.