Rule A13-1-2 (required, implementation, automated)
User defined suffixes of the user defined literal operators shall start with underscore followed by one or more letters.
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