467,864 Members | 1,732 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 467,864 developers. It's quick & easy.

Pseudo destructor

ISO/IEC 14882:2003:

"5.2.4 Pseudo destructor call [expr.pseudo]

The use of a pseudo-destructor-name after a dot . or arrow -> operator
represents the destructor for the non-class type named by
type-name. The result shall only be used as the operand for the
function call operator (), and the result of such a call has type
void. The only effect is the evaluation of the postfix- expression
before the dot or arrow.

The left hand side of the dot operator shall be of scalar type. The
left hand side of the arrow operator shall be of pointer to scalar
type. This scalar type is the object type. The type designated by the
pseudo-destructor-name shall be the same as the object type.
Furthermore, the two type-names in a pseudo-destructor-name of the

::opt nested-name-specifieropt type-name :: ~ type-name

shall designate the same scalar type. The cv-unqualified versions of
the object type and of the type desig- nated by the
pseudo-destructor-name shall be the same type."
Hatton's Law: "There is only One inviolable Law"
KDevelop: http://www.kdevelop.org SuSE: http://www.suse.com
Mozilla: http://www.mozilla.org
Jul 22 '05 #1
  • viewed: 2820
1 Reply

"Steven T. Hatton" <su******@setidava.kushan.aa> wrote in message news:pvydnSp6hqj5bIPcRVn->

You don't elaborate on what you don't understand. But let me expound on the passage
you quoted.

Class types all have either explicit or implicit "REAL" destructors '(if you don't define
a destructor one will be defined for you). Other types, like ints for example, don't
really have destructor. However, primarily for the benefit of templates, you're allowed
to make what appears to be a destructor call to them.

Some of the templated containers, such as vectors, make use of this. They will destruct
and element to get "rid" of the instance without freeing the memory and then placement
construct a new one on top of the existing memory. Without the psuedo destructor,
they'd have to specialize the template for non class types to get rid of the destructor

Jul 22 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

52 posts views Thread by Newsnet Customer | last post: by
11 posts views Thread by Stub | last post: by
70 posts views Thread by Ben Pfaff | last post: by
11 posts views Thread by Ken Durden | last post: by
35 posts views Thread by Peter Oliphant | last post: by
11 posts views Thread by AB | last post: by
23 posts views Thread by Ben Voigt | last post: by
8 posts views Thread by gw7rib | last post: by
7 posts views Thread by sam | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.