Title
Insufficient restrictions on parameters of postfix operators
Status
drafting
Section
12.4 [over.oper]
Submitter
Richard Smith

Created on 2014-08-30.00:00:00 last changed 125 months ago

Messages

Date: 2014-08-30.00:00:00

According to 12.4.7 [over.inc] paragraph 1,

The user-defined function called operator++ implements the prefix and postfix ++ operator. If this function is a non-static member function with no parameters, or a non-member function with one parameter, it defines the prefix increment operator ++ for objects of that type. If the function is a non-static member function with one parameter (which shall be of type int) or a non-member function with two parameters (the second of which shall be of type int), it defines the postfix increment operator ++ for objects of that type.

According to 12.4 [over.oper] paragraph 8,

Operator functions cannot have more or fewer parameters than the number required for the corresponding operator, as described in the rest of this subclause.

This does not rule out an operator++ with more than two parameters, however, since there is no corresponding operator.

One possibility might be to add a sentence like,

A function named operator++ shall declare either a prefix or postfix increment operator.
History
Date User Action Args
2014-08-30 00:00:00admincreate