US-18: Removing User-Defined Literals

Author: Douglas Gregor
Contact: doug.gregor@gmail.com
Organization: Apple
Date: 2011-02-28
Number: N3250=11-0020

Introduction

This proposal recommends the removal of user-defined literals (N2765) from the C++0x working paper, per National Body comment US-18. The author believes that user-defined literals should be considered as a feature for future language standards, but that the risks associated with keeping this feature in the C++0x working paper far outweigh the benefits.

User-defined literals should be removed from the C++0x working paper for the following reasons:

Overall, we have a feature that has no implementation or usage experience, conflicts with existing practice in the C99 standard without providing the promised compatibility improvements.

Proposed Wording

Modify section 2.5 [lex.pptoken] as follows:

  1. preprocessing-token:
      header-name
      identifier
      pp-number
      character-literal
      user-defined-character-literal
      string-literal
      user-defined-string-literal
      preprocessing-op-or-punc
      each non-white-space character that cannot be one of the above
    
  2. A preprocessing token is the minimal lexical element of the language in translation phases 3 through 6. The categories of preprocessing token are: header names, identifiers, preprocessing numbers, character literals (including user-defined character literals), string literals (including user-defined string literals), preprocessing operators and punctuators, and single non-white-space characters that do not lexically match the other preprocessing token categories.

Modify section 2.10 [lex.ppnumber] as follows:

  1. pp-number:
      digit
      . digit
      pp-number digit
      pp-number identifier-nondigit
      pp-number e sign
      pp-number E sign
      pp-number .
    

Modify 2.14.1 [lex.literal.kinds] as follows:

  1. There are several kinds of literals.
    literal:
      integer-literal
      character-literal
      floating-literal
      string-literal
      boolean-literal
      pointer-literal
      user-defined-literal
    

Remove section 2.14.8 [lex.ext].

Modify 3 [basic] as follows:

  1. Two names are the same if

Modify 5.1.1 [expr.prim.general]p1 as follows:

  1. unqualified-id:
      identifier
      operator-function-id
      conversion-function-id
      literal-operator-id
      ~ class-name
      ~ decltype-specifier
      template-id
    
  1. An identifier is an id-expression provided it has been suitably declared (Clause 7). [Note: for operator-function-ids, see 13.5; for conversion-function-ids, see 12.3.2; for literal-operator-ids, see 13.5.8; for template-ids, see 14.2. A class-name or decltype-specifier prefixed by ~ denotes a destructor; see 12.4.

Remove section 13.5.8 [over.literal].

Remove section 17.6.3.3.5 [usrlit.suffix].


Last modified: Mon Feb 28 06:52:59 PST 2011