AutosarC++17_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
| Level | required |
|---|---|
| Target | implementation |
| Enforcement | automated |
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¶
This rule shares the following common options: confidence, 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
suffix_pattern¶
suffix_pattern : typing.Pattern[str] = '^_[^\W\d]+$'
operator ""
(e.g., _km in operator "" _km).