Boost logo

Boost Users :

Subject: Re: [Boost-users] for_each on boost::ptr_map
From: Peter Barker (newbarker_at_[hidden])
Date: 2008-09-16 10:25:01


> At risk of sounding a complete wally, I have completely failed to understand
> why the second version is any way preferrable to the first.
>
> Why would you want to do this?
>
> - Rob.

Are you asking why you would you use a boost::ptr_map over a std::map?
I believe it's so the container takes ownership of the pointed to
objects. http://www.boost.org/doc/libs/1_35_0/libs/ptr_container/doc/ptr_container.html#motivation
contains this line:

"For each of the standard containers there is a pointer container
equivalent that takes ownership of the objects in an exception safe
manner. In this respect the library is intended to solve the so-called
polymorphic class problem."

Regards,

Pete


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