Note: C++0x is a new version
of the C++ programming language standard. This is a draft standard
and has not been officially adopted in its entirety. The implementation
of C++0x is based on IBM's interpretation of the draft
C++0x standard and is subject to change at any time without notice.
IBM makes no attempt to maintain compatibility with earlier releases
and therefore the C++0x language extension should not be relied on
as a stable programming interface.
Syntactically, delegating constructors and target
constructors present the same interface as other constructors,
see Delegating constructors (C++0x).
Consider the following points when you use the delegating constructors
feature:
- Call the target constructor implementation in such a way that
virtual bases, direct nonvirtual bases, class members and additional
ABI artifacts are initialized by target constructor as appropriate.
- Respond to the exception thrown in the body of a delegating constructor
by calling the destructor implementation on the object that is constructed
through the target constructor. The destructor implementation must
be called in such a way that it calls the destructors of subobjects
as appropriate. In particular, it must call the destructors for virtual
base classes if the virtual base classes are created through the target
constructor.
- Perform proper construction and destruction when initializing
static objects with delegating constructors and on termination of
a program that does such initialization.
- When an exception is thrown, a corresponding destructor must be
called. Otherwise, virtual bases may have their destructors called
more than once or not at all. With a delegating constructor, the call
to the target constructor does not necessarily match a specific destructor
implementation.
- The feature has minimal impact on compile time and run time performance.
However, use of default arguments with an existing constructor is
recommended in place of a delegating constructor where possible. Without
inlining and interprocedural analysis, run time performance may degrade
because of function call overhead and increased opacity.