12 Overloading [over]

12.4 Overloaded operators [over.oper]

12.4.7 Increment and decrement [over.inc]

12.4.7.2 Defaulted function [over.inc.default]

A defaulted postfix increment or decrement operator function for a type C shall be a non-template function that
  • has a first parameter of type “reference to C” or a first parameter of type “reference to volatile C”, where the implicit object parameter (if any) is considered to be the first parameter,
  • is defined as defaulted in C or in a context where C is complete, and
  • has a declared return type of C.
[Note 1: 
A postfix increment or decrement operator always has a parameter of type int ([over.inc.general]).
— end note]
Name lookups and access checks in the implicit definition ([dcl.fct.def.default]) of a defaulted postfix increment or decrement operator function are performed from a context equivalent to its function-body.
A definition of a postfix increment or decrement operator as defaulted that appears in a class shall be the first declaration of that function.
[Example 1: struct S; S operator++(S&, int) = default; // error: S is not complete — end example]
A defaulted postfix increment or decrement operator function for a type C is defined as deleted if
  • C is a class type for which overload resolution ([over.match]), as applied to direct-initialization of a variable of type C from an lvalue of type C, does not result in a usable candidate,
  • C has a destructor that is deleted or inaccessible from the context of the function-body, or
  • for an lvalue c of type C, overload resolution as applied to ++c for a postfix increment operator function or --c for a postfix decrement operator function does not result in a usable candidate.
The implicit definition of a defaulted postfix increment or decrement operator function F that is not defined as deleted for a type C is equivalent to C tmp(c); ++c; return tmp; for a postfix increment operator function, or C tmp(c); --c; return tmp; for a postfix decrement operator function, where tmp is a variable defined for exposition only, and c is an lvalue that denotes *this if F is an implicit object member function, or the first parameter of F otherwise.
[Example 2: struct S{ S(const S&) = default; S& operator++() { return *this; } }; S operator++(S, int) = default; // error: incorrect parameter type struct T{ T operator++(int) = default; // OK, defined as deleted }; enum class E1 {}; E1 operator++(E1&, int) = default; // OK, defined as deleted; built-in operator++ // does not exist for enumeration types enum E2 {}; E2& operator++(E2& e); E2 operator++(E2&, int) = default; // OK, not deleted — end example]