User-defined literals (since C++11)

Allows integer, floating-point, character, and string literals to produce objects of user-defined type by defining a user-defined suffix.

# Notes

Since the introduction of user-defined literals, the code that uses format macro constants for fixed-width integer types with no space after the preceding string literal became invalid: std::printf("%"PRId64"\n",INT64_MIN); has to be replaced by std::printf("%" PRId64"\n",INT64_MIN);.

Due to maximal munch, user-defined integer and floating point literals ending in p, P,(since C++17) e and E, when followed by the operators + or -, must be separated from the operator with whitespace or parentheses in the source:

Same applies to dot operator following an integer or floating-point user-defined literal:

Otherwise, a single invalid preprocessing number token (e.g., 1.0_E+2.0 or 4s.count) is formed, which causes compilation to fail.

# Defect reports

DRApplied toBehavior as publishedCorrect behavior
CWG 1473C++11whitespace between "" and ud-suffix wasrequired in the declaration of literal operatorsmade optional
CWG 1479C++11literal operators could have default argumentsprohibited
CWG 2521C++11operator"" _Bq was ill-formed (no diagnosticrequired) because it uses the reserved identifier _Bqdeprecated the literal operator syntaxwith whitespace between "" and ud-suffix