Boost logo

Boost :

From: Thorsten Ottosen (tottosen_at_[hidden])
Date: 2006-01-06 13:14:28


David Maisonave wrote:
> "Thorsten Ottosen" <tottosen_at_[hidden]> wrote in message

>>I'm not sure I fully understand how the detection mechanism would work
>>in your cow_ptr.
>
>
> Example code:
> template<typename T_obj>
> cow_ptr(T_obj* type): m_ref_count(new ref_count(type,
> get_alloc_func(type)))
> {
> assert(typeid(*type) == typeid(T_obj));
> }

how can that assertion ever fail when T_obj is deduced?

> Since the cow_ptr works by capturing the type on the constructor, it can
> easily determine if the right type is being passed in, and if it matches
> the pointee type.
> That can't be done with the boost pointer containers because they don't
> catch the type on the constructor, nor is it part of the required logic
> for using a clone function method.
>
>
>>Nevertheless, as soon as the object is outside
>>a cow_ptr might be sliced. That's reason enough not to allow it.
>
>
> I'm not sure what you're referring to here. Can you post an example?

*ptr = *ptr2;

-Thorsten


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