Boost logo

Boost :

From: Eric Woodruff (Eric.Woodruff_at_[hidden])
Date: 2002-12-10 12:27:52


"Peter Dimov" <pdimov_at_[hidden]> wrote in message
news:003f01c2a06f$2c4f6550$1d00a8c0_at_pdimov2...
> From: "Eric Woodruff" <Eric.Woodruff_at_[hidden]>
> > Using g++ 2.95.4,
> >
> > #include <iostream>
> > #include <boost/shared_ptr>
>
> Changed to <boost/shared_ptr.hpp>.
>

Mistyped in the message, but was correct in the code.

> > struct Object {
> > ~Object () {
> > std::cout << "byebye" << std::endl;
> > }
> > };
> >
> > int main () {
> > Object o; // destructs
> > boost::shared_ptr<void> (new Object); // does not destruct, however
> > apprears to delete
> > std::cout << "done." << std::endl;
> > }
>
> C:\Documents and Settings\pdimov\My
Documents\Projects\testbed>g++ --version
> 2.95.3-6
>
> C:\Documents and Settings\pdimov\My Documents\Projects\testbed>g++
> testbed.cpp
>
> C:\Documents and Settings\pdimov\My Documents\Projects\testbed>a
> byebye
> done.
> byebye
>
> Note that you are constructing an unnamed temporary shared_ptr<void>,
which
> is why it destructs before "done." is printed.

Doesn't make any difference with the outcome in theory or in my test as I
just tried it.

int main () {
boost::shared_ptr<void> p (new Object);
}

No destructor printed.


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