Title
Default arguments for operator[]
Status
cd6
Section
12.4.1 [over.oper.general]
Submitter
Jens Maurer

Created on 2021-12-07.00:00:00 last changed 3 months ago

Messages

Date: 2021-12-15.00:00:00

Proposed resolution (December, 2021):

Change 12.4.5 [over.sub] paragraph 1 as follows:

A subscripting operator function is a function named operator[] that is a non-static member function with an arbitrary number of parameters. It may have default arguments. For an expression...

Approved by EWG 2022-04-14.

Approved by CWG 2022-04-22.

Date: 2022-07-15.00:00:00

[Accepted at the July, 2022 meeting.]

The intent of paper P2128R6, which permitted multiple parameters in overloaded subscript operators and was adopted at the October, 2021 plenary, was that overloaded operator[] should allow parameters with default arguments. However, the adopted wording did not address the following restriction from 12.4.1 [over.oper.general] paragraph 10:

An operator function cannot have default arguments (9.3.4.7 [dcl.fct.default]), except where explicitly stated below.

Similar wording to that of operator() should be added for operator[].

History
Date User Action Args
2022-08-19 07:54:33adminsetstatus: ready -> cd6
2022-04-22 21:07:05adminsetstatus: review -> ready
2022-01-06 00:00:00adminsetmessages: + msg6605
2021-12-07 00:00:00admincreate