Boost logo

Boost :

From: Thorsten Ottosen (tottosen_at_[hidden])
Date: 2006-01-03 20:12:12


axter wrote:
>
>
> I think the cow_ptr should be used as the default method for creating
> containers of pointers, and that the current boost pointer containers should
> be used when memory management is the more important factor for a particular
> requirement.

Their primary purpose is to facilitate OOP in C++. This domain is
sufficiently different from the value-based domain that different
programming idioms apply.

> I'm not sure about the ptr_set and ptr_map classes, because I haven't seen
> any example code usage that would have it work with an abstract type.

Listen, when you said you could get it to work with an abstract type, I
tried it out.

It works fine, but one gets errors if one does not define new_clone()
for the abstract type:

namespace Foo
{
   struct abtract_base { ... };

   inline new_clone( const abstract_base& r )
   { return r.clone(); }
}

My guess is that most of the other compile problems go away when you
define this.

Did you not read

http://www.boost.org/libs/ptr_container/doc/reference.html#the-clonable-concept

?

The default new_clone() won't work when T is abstact:

     template< class T >
     inline T* new_clone( const T& t )
     {
         return new T( t );
     }

-Thorsten


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