Boost logo

Boost Users :

Subject: Re: [Boost-users] [ptr_container] ptr_map and cloning issues
From: John Wilkinson (jwilkinson_at_[hidden])
Date: 2009-02-06 10:03:40


________________________________________
From: boost-users-bounces_at_[hidden] [mailto:boost-users-bounces_at_[hidden]] On Behalf Of Robert Dailey
Sent: Friday, February 06, 2009 8:57 AM
To: boost-users_at_[hidden]
Subject: Re: [Boost-users] [ptr_container] ptr_map and cloning issues

> > First, this compiles without any problems for me:
> >
> >   class Texture;
> >   typedef boost::ptr_map<std::string,Texture> MapType;
> >
> >   void foo( const MapType& m )
> >   {
> >       //MapType map;
> >       MapType::const_iterator i = m.find( "foo" );
> >       //i = map.find( "foo" );
> >   }

> At first you said "...this compiles without any problems for me" and then
> you said "...the uncommented does not compile...". So which is it?

It's the commented-out code that will not compile. When the instance of MapType goes out of scope, the type of the contained pointers cannot be unknown, because they have to be deleted.

John


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net