On 20 Nov 2017, at 16:57, Peter Dimov via Boost
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