Boost logo

Boost :

From: ERICSSON,JOHAN (A-Sonoma,ex1) (johan_ericsson_at_[hidden])
Date: 2001-11-16 16:14:47

-----Original Message-----
From: Jeff King [mailto:peff-boost_at_[hidden]]
Sent: Friday, November 16, 2001 11:19 AM
To: boost_at_[hidden]
Subject: RE: [boost] polymorphic containers

On Fri, 16 Nov 2001, ERICSSON,JOHAN (A-Sonoma,ex1) wrote:

>> 1. Don't allow the poly_ptr to have a NULL value. This simplifies both
>> implementation of poly_ptr and the client significantly. The client no
>> longer has to check for a NULL poly_ptr. If the client needs an optional

>I wanted to do that at first, but I also wanted poly_ptr to be default
>constructible for use with standard containers. I'm not sure if it would
>be possible to have a poly_ptr that default constructed a pointer to
>'parent'. If parent is an ABC, it won't even compile (whether or not you
>try to use the default constructor).

The standard containers don't require an object to be default constructable.
The constructor that takes the size of the vector has an optional second
parameter that allows one to copy-construct all the new elements, rather
than use the default constructor.

I don't think that non-default constructable elements are any more difficult
to use with standard containers.

>> Anyways, I think a poly_ptr object still has value over a broader variant
>> object. The usage of the poly_ptr is bound to be easier.

> Really? I took a look at the variant class; it seems quite friendly (at
> least as friendly as poly_ptr). Do you have specific complaints about it
> as compared to poly_ptr?

I have to admit that I didn't look too carefully at the variant class code.
On second thought, it does look very cool. The way it avoids using an
invasive clone-ing method is really nice.

My only qualm would be that I would prefer that it didn't have a default
constructor, for the same reasons as I mentioned for poly_ptr. Its no fun
having to do "if (p.get()) p->DoSomething()" all over the place.

Also, not sure if variant is the right name. When I think 'variant', I think
of the 'any' class. Not sure if the names distinguish where their uses

For now, I'm going to continue using my dumbed down version of poly_ptr
simply because its implementation is simple.


Boost list run by bdawes at, gregod at, cpdaniel at, john at