CWG Issue 1473 (original) (raw)

This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 117a. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.

2025-04-13


1473. Syntax of literal-operator-id

Section: 12.6 [over.literal]Status: CD3Submitter: Richard SmithDate: 2012-03-05

[Moved to DR at the April, 2013 meeting.]

The current grammar requires that there be no whitespace between the literal and the ud-suffix, e.g., ""_abc, but that there be whitespace between the "" and the identifier in a_literal-operator-id_, e.g., operator "" _abc. This seems unfortunate. Would it be possible to provide an alternate production,

operator user-defined-string-literal

with the requirement that the string-literal be empty?

The current wording is also unclear regarding interactions with phases of translation. We have the following production:

literal-operator-id: operator "" identifier

As this is after translation phase 6, would something like

operator "" "" _foo

be accepted?

Proposed resolution (October, 2012):

  1. Change 12.6 [over.literal] as follows: literal-operator-id: operator "" string-literal identifier
    operator user-defined-string-literal
  2. Change 12.6 [over.literal] paragraph 1 as follows:

The string-literal or user-defined-string-literal in a_literal-operator-id_ shall have no encoding-prefix and shall contain no characters other than the implicit terminating'\0'. The ud-suffix of the_user-defined-string-literal_ or the identifier in a_literal-operator-id_ is called a literal suffix identifier. [_Note:_ some literal suffix identifiers are reserved for future standardization; see 16.4.5.3.6 [usrlit.suffix]. —_end note_]

  1. Change the example in 12.6 [over.literal] paragraph 8 as follows:

void operator "" _km(long double); // OK string operator "" _i18n(const char*, std::size_t); // OK template <char...> int operator "" \u03C0(); // OK: UCN for lowercase pi float operator ""E(const char*); // error: ""E (with no intervening space) // is a single token OK float operator " " B(const char*); // error: non-adjacent quotesempty string-literal string operator "" 5X(const char*, std::size_t); // error: invalid literal suffix identifier double operator "" _miles(double); // error: invalid parameter-declaration-clause template <char...> int operator "" _j(const char*); // error: invalid parameter-declaration-clause