Literal descriptors must be defined in their own C++ statement and the resulting constant used wherever it is required.
Literal descriptors cannot be embedded in expressions because they do not create temporary objects.
Literal objects can be declared safely in header files:
without requiring writable data
without creating a copy of the data in every module that includes the header.
Literals can be defined at file-scope, including in header files, in which case they are visible to any code that follows. They can also be declared local to the function which uses them. However, there are a couple of caveats with defining them at function scope:
For very short strings, of the order of 3 ASCII characters or 1 UNICODE character, it is more efficient to declare the literals at file scope.
Literal descriptors defined in inline functions are laid down in every single compilation module that includes the header file.
Thus, if the descriptor is short or used only in an inline function, it is better to define it at file scope with a suitably distinct name.