On 20 Nov 2017, at 00:41, Peter Dimov via Boost
wrote: Peter Bartlett wrote:
The only nit I had in the paper was that after all the banging on about it being a value type, we are given operator bool, operator* and operator->, making it pointer-like again. Could operator T& and operator T const& work?
Polymorphic means virtual functions, and when you have a polymorphic_value<T> pv, where T has a virtual function `f`, you can call `pv->f()`. With a conversion to T&, you can't call `pv.f()`.
I had a careful think about this. It seems to me that what is at fault is not the interface, but the name. For the reason of the example below, it is helpful that the interface is consistent with unique_ptr, reference_wrapper, and shared_ptr. However, I think it is fair to say that the suffix _value is misleading as to intent. Example: struct FooConcept { void operator()() const; virtual ~FooConcept() = default; }; template class OwnershipHandle> struct basic_foo_handle { using implementation_pointer = OwnershipHandle<FooConcept>; void operator()() const { (*impl_)(); } implementation_pointer impl_; }; // a unique, non-copyable Foo using unique_foo = basic_foo_handlestd::unique_ptr(); // a shared-body Foo using shared_foo = basic_foo_handlestd::shared_ptr(); // observer_ptr would be a more consistent concept name (what happened to that?) using foo_reference = basic_foo_handlestd::reference_wrapper(); // deep_copy_ptr might have been a more appropriate name? using copyable_foo = basic_foo_handleboost::polymorphic_value();
_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost