operator-function-id: operator operator
operator: one of new delete new[] delete[] co_await ( ) [ ] -> ->* ~ ! + - * / % ^ & | = += -= *= /= %= ^= &= |= == != < > <= >= <=> && || << >> <<= >>= ++ -- ,
. .* :: ?:
nor can the preprocessing symbols
# ([cpp.stringize])
and
## ([cpp.concat]).complex z = a.operator+(b); // complex z = a+b; void* p = operator new(sizeof(int)*n);— end example
cast-expression . operator @ ()Otherwise, if a non-member function is selected, the expression is interpreted as
operator @ ( cast-expression )
struct B { virtual int operator= (int); virtual B& operator= (const B&); }; struct D : B { virtual int operator= (int); virtual D& operator= (const B&); }; D dobj1; D dobj2; B* bptr = &dobj1; void f() { bptr->operator=(99); // calls D::operator=(int) *bptr = 99; // ditto bptr->operator=(dobj2); // calls D::operator=(const B&) *bptr = dobj2; // ditto dobj1 = dobj2; // calls implicitly-declared D::operator=(const D&) }— end example
postfix-expression ( expression-list )where the postfix-expression is of class type, the operator function is selected by overload resolution ([over.call.object]).
postfix-expression . operator conversion-type-id () ( expression-list )Otherwise, the expression is interpreted as
postfix-expression . operator () ( expression-list )
postfix-expression [ expr-or-braced-init-list ]the operator function is selected by overload resolution ([over.match.oper]).
postfix-expression . operator [] ( expr-or-braced-init-list )
postfix-expression -> template id-expressionthe operator function is selected by overload resolution ([over.match.oper]), and the expression is interpreted as
( postfix-expression . operator -> () ) -> template id-expression
struct X { X& operator++(); // prefix ++a X operator++(int); // postfix a++ }; struct Y { }; Y& operator++(Y&); // prefix ++b Y operator++(Y&, int); // postfix b++ void f(X a, Y b) { ++a; // a.operator++(); a++; // a.operator++(0); ++b; // operator++(b); b++; // operator++(b, 0); a.operator++(); // explicit call: like ++a; a.operator++(0); // explicit call: like a++; operator++(b); // explicit call: like ++b; operator++(b, 0); // explicit call: like b++; }— end example