AutosarC++18_10-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
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¶
This rule shares the following common options: exclude_in_macros, exclude_messages_in_system_headers, excludes, extend_exclude_to_macro_invocations, includes, justification_checker, languages, post_processing, provider, report_at, severity
The following places define options that affect this rule: Stylechecks, Analysis-GlobalOptions
allow_unicode_identifiers¶
allow_unicode_identifiers : bool = False
check_for_leading_space¶
check_for_leading_space : bool = False