[expr.prim.id.dtor] (original) (raw)
7 Expressions [expr]
7.5 Primary expressions [expr.prim]
7.5.4 Names [expr.prim.id]
7.5.4.3 Destruction [expr.prim.id.dtor]
An id-expression that denotes the destructor of a type Tnames the destructor of Tif T is a class type ([class.dtor]), otherwise the id-expression is said to name a pseudo-destructor.
If the id-expression names a pseudo-destructor,T shall be a scalar type and the id-expression shall appear as the right operand of a class member access ([expr.ref]) that forms the postfix-expression of a function call ([expr.call]).
[ Note
:
Such a call ends the lifetime of the object ([expr.call], [basic.life]).
— end note
]
[ Example
:
struct C { };
void f() {
C * pc = new C;
using C2 = C;
pc->C::C2(); // OK, destroys *pc
C().C::C(); // undefined behavior: temporary of type C destroyed twice
using T = int;
0 .T::T(); // OK, no effect
0.T::T(); // error: 0.T is a user-defined-floating-point-literal ([lex.ext])
}
— end example
]