|
Boost : |
Subject: Re: [boost] Adding polymorphic_value to boost
From: Jonathan Coe (jonathanbcoe_at_[hidden])
Date: 2017-11-20 17:07:25
> On 20 Nov 2017, at 16:57, Peter Dimov via Boost <boost_at_[hidden]> wrote:
>
> Jonathan Coe wrote:
>
>> The pointer constructor is needed in migration paths from class heirarchies with a `Clone()` method. It also allows one to support objects coming from C_APIs.
>
> Supporting
>
> X* create(...);
> X* copy( X const* );
> void destroy( X* );
>
> is appropriate for a cloning pointer, but hasn't really much to do with polymorphic values.
>
> struct Shape
> {
> virtual ~Shape() = default;
> Shape* clone() const = 0;
> void draw() = 0;
> };
>
> Shape* createCircle( int r );
>
> is admittedly less clear-cut.
>
> Looking at my old code, what I did was supply both a cloning pointer (U*) and a polymorphic value (U&&) types, the latter a simple wrapper over the former.
>
This was my original design too which was strongly opposed by LEWG.
> _______________________________________________
> Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk