Boost logo

Boost :

From: Rainer Deyke (root_at_[hidden])
Date: 2001-04-04 14:18:03


----- Original Message -----
From: "Arun Sivaramakrishnan" <aruns_at_[hidden]>
To: <boost_at_[hidden]>
Sent: Wednesday, April 04, 2001 9:39 AM
Subject: Re: [boost] Re: scoped_ptr: trivial dtor?
> > Then there shouldn't be a problem. Declaring '~C' in 'C' and placing
the
> > definition for 'C::~C' below the definition for 'Cimpl' causes 'Cimpl'
to
> be
> > a complete type at the point where 'scoped_ptr<Cimpl>::~scoped_ptr' is
> > called. 'Cimpl' doesn't even need a trivial destructor.
>
> To compile C.cpp ,yes we dont need CImpl to be trivial ,but in other
> translation units
> where the C.h is included and C -objects might be used ,CImpl and its
> destructor would'nt be visible then,would it? So to use the idiom we do
need
> CImpl to be trivial ,dont we?.I guess this puts me back to where we
started.
> Somebody please clarify!

Consider this:

class C {
public:
  ~C();
private:
  boost::scoped_ptr<Cimpl> impl;
};

void f() {
  C c;
}

Object 'c' is destroyed when it leaves the scope of 'f'. When this happens,
'C::~C' is called. 'f' doesn't care about how the data members of 'c' are
destroyed. Destroying them is the responsibility of 'C::~C'. 'f' just
requires that 'C::~C' does its job.

--
Rainer Deyke (root_at_[hidden])
Shareware computer games           -           http://rainerdeyke.com
"In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk