Topic: functional cast vs. copy constructor question
Author: Sandra Loosemore <sandra@shore.net>
Date: 2000/01/22 Raw View
I've run across some code that seems to expect that a functional cast of
a class object to its own type will use the class's copy constructor
to initialize a temporary, instead of acting as an identity operation.
Section 5.2.3 of the standard says a functional cast with one argument
is identical in meaning to a regular cast expression -- X(x) is the same
as (X)x. And 5.2.11 at least implies that casting an object to its own
type is a no-op.
Is the stuff in section 12.1 about invoking the constructor in a
functional type conversion expression supposed to override the
behavior otherwise specified in section 5.2.3 for the 1-argument case,
or only apply to the 0- or multi-argument cases where it is clear that
the appropriate constructor should be called?
-Sandra
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html ]