Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2002-12-10 12:11:23


From: "Eric Woodruff" <Eric.Woodruff_at_[hidden]>
> Using g++ 2.95.4,
>
> #include <iostream>
> #include <boost/shared_ptr>

Changed to <boost/shared_ptr.hpp>.

> 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.


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