I know this is an old feature but reading on user defined literals e.g.
return_t operator "" _a(long); // Literal operator for user-defined INTEGRAL literal
I was reminded that
the leading underscore is required. (Only the Standard Library is allowed to define literals without the underscore.) (A)
This seems to break pattern since so far the implementation worked with the underscorey names and left us the good ones, for example reserved to the implementation are names that
Furthermore quote (A) is somewhat dangerous in the presence of rule (2). So why the inconsistency?
Before the idea of user-defined literals was added to the language, all the standard literals used sequences that don't begin with underscore, such as 123L
for a long int
literal. So to maintain consistency, standard literals get the namespace without any special prefix, and UDLs are distinguished from them by using _
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With