This is the mail archive of the
libstdc++@sourceware.cygnus.com
mailing list for the libstdc++ project.
Re: auto_ptr bug
- To: Brad Garcia <bgarcia at laurelnetworks dot com>
- Subject: Re: auto_ptr bug
- From: Branko Čibej <branko dot cibej at hermes dot si>
- Date: Mon, 10 Apr 2000 21:18:19 +0200
- CC: libstdc++ at sourceware dot cygnus dot com
- Organization: HERMES SoftLab
- References: <Pine.LNX.4.21.0004101442580.18885-100000@spud.laurelnetworks.com>
Brad Garcia wrote:
> So, getting to my real problem: how can I make a map full of Foo's, and
> have them get destroyed when the map is destroyed, given that the Foo's
> themselves cannot be copied?
I think your best bet is to use a reference-counted pointer.
There are several implementations floating around; see, for
instance, http://www.boost.org/ .
> I thought auto_ptr was the answer, but apparently it isn't anymore?
> Or should pair<> define another constructor that takes non-const
> arguments (this is what prevents me from using auto_ptr in a map<>)?
No, auto_ptr can't be used in containers, and on purpose.
--
Branko Čibej <branko.cibej@hermes.si>
HERMES SoftLab, Litijska 51, 1000 Ljubljana, Slovenia
voice: (+386 1) 586 53 49 fax: (+386 1) 586 52 70