S
Stefan Ram
I used to say that a literal is defined by the programming
language while a name is defined by the user. For example,
the value of »5« is defined by C++, while the value of »i«
in »constexpr int i = 3;« is defined by the user.
With user-defined literals, however, this is no longer true.
The value of a literal such as »5m« can now be defined by
the user.
So what is a literal, then?
One might try to say that the value of a literal can be
determined from its characters in a systematic manner, for
example, 417, 418, 419, 420, 421 versus names such as ijk,
ijl, ijm, ijn, but the values of the literals »true« and
»false« cannot be derived from their characters by a rule.
One might say that names start with name-start characters,
such as letters, while literals start with other characters,
such as digits, but the literal »R"(abc)"« starts with a
character that could start a name as well.
So, can we give a general meaningful definition for the
meaning of the word »literal« other than somewhat
tautological wordings like »a literal is everything that
ISO 14882:2011 defines to be a literal«?
language while a name is defined by the user. For example,
the value of »5« is defined by C++, while the value of »i«
in »constexpr int i = 3;« is defined by the user.
With user-defined literals, however, this is no longer true.
The value of a literal such as »5m« can now be defined by
the user.
So what is a literal, then?
One might try to say that the value of a literal can be
determined from its characters in a systematic manner, for
example, 417, 418, 419, 420, 421 versus names such as ijk,
ijl, ijm, ijn, but the values of the literals »true« and
»false« cannot be derived from their characters by a rule.
One might say that names start with name-start characters,
such as letters, while literals start with other characters,
such as digits, but the literal »R"(abc)"« starts with a
character that could start a name as well.
So, can we give a general meaningful definition for the
meaning of the word »literal« other than somewhat
tautological wordings like »a literal is everything that
ISO 14882:2011 defines to be a literal«?