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

2023-01-15


1479. Literal operators and default arguments

Section: 12.6  [over.literal]     Status: CD3     Submitter: Jason Merrill     Date: 2012-03-13

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

It appears that an example like

  int operator"" _a (const char *, std::size_t = 0);
  int operator"" _a (const char *);

  int i = 123_a;

is ambiguous: although only the second declaration is a raw literal operator, the corresponding call

  operator"" _a ("123")

could match either declaration. Should default arguments for literal operators be prohibited?

Proposed resolution (October, 2012):

Change 12.6 [over.literal] paragraph 3 as follows:

The declaration of a literal operator shall have a parameter-declaration-clause equivalent to one of the following:

...

If a parameter has a default argument (9.3.4.7 [dcl.fct.default]), the program is ill-formed.