Title
Syntax of literal-operator-id
Status
cd3
Section
12.6 [over.literal]
Submitter
Richard Smith

Created on 2012-03-05.00:00:00 last changed 90 months ago

Messages

Date: 2013-04-15.00:00:00

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

Date: 2012-10-15.00:00:00

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:

  3. 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]
  4. Change the example in 12.6 [over.literal] paragraph 8 as follows:

  5.   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
    
Date: 2012-03-05.00:00:00

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?

History
Date User Action Args
2014-03-03 00:00:00adminsetstatus: drwp -> cd3
2013-10-14 00:00:00adminsetstatus: dr -> drwp
2013-05-03 00:00:00adminsetmessages: + msg4423
2013-05-03 00:00:00adminsetstatus: tentatively ready -> dr
2012-11-03 00:00:00adminsetmessages: + msg4078
2012-11-03 00:00:00adminsetstatus: open -> tentatively ready
2012-03-05 00:00:00admincreate