Boost logo

Boost :

Subject: Re: [boost] [ptr_container] ptr_vector across DLL boundaries
From: Stewart, Robert (Robert.Stewart_at_[hidden])
Date: 2009-06-26 09:34:48


On Friday, June 26, 2009 6:35 AM
Thorsten Ottosen wrote:
> Christian Schladetsch skrev:
>
> >> Types in object hierarchies usually don't expose their
> >> copy-constructor to avoid slicing.
> >
> > But again, isn't this out of the scope? It's like the tail
> > wagging the dog - ptr_container shouldn't really be concerned
> > with object hierarchies or not. That's up to the user.
[snip]
> >> Furthermore, and more importantly, you lose the concrete
> >> type of the objects by having a container of pointers to the
> >> base class. Virtual functions are the most elegant way to
> >> ask the object for a copy of the right type.
> >
> > Isn't this about ptr_container? We can't really have the
> > specific usage of OO hierarchies with containers of base
> > pointers dictate the implementation of an otherwise general
> > system.
>
> Please understand that pointer containers are written almost for the
> sole purpose of supporting OO programming better.

I know of use cases in which a similar container is used to hold
homogeneous collections of objects by pointer, so cloning is
irrelevant. Indeed, I recall that Rogue Wave had such containers
available. Here's one: http://www2.roguewave.com/support/docs/hppdocs/tlsref/rwtptrvector.html.

Can't cloning be handled using a smart pointer in a value-based
container? That is, rather than make the pointer containers try
to manage cloning, let them assume T is the most derived type
rather than what might be a base type, and then supply a smart
pointer for use with value-based containers to enable cloning.
The smart pointer can call T::clone() or defer to a policy class
to copy the T * it holds.

_____
Rob Stewart robert.stewart_at_[hidden]
Software Engineer, Core Software using std::disclaimer;
Susquehanna International Group, LLP http://www.sig.com

IMPORTANT: The information contained in this email and/or its attachments is confidential. If you are not the intended recipient, please notify the sender immediately by reply and immediately delete this message and all its attachments. Any review, use, reproduction, disclosure or dissemination of this message or any attachment by an unintended recipient is strictly prohibited. Neither this message nor any attachment is intended as or should be construed as an offer, solicitation or recommendation to buy or sell any security or other financial instrument. Neither the sender, his or her employer nor any of their respective affiliates makes any warranties as to the completeness or accuracy of any of the information contained herein or that this message or any of its attachments is free of viruses.


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