Boost logo

Boost :

Subject: [boost] Fwd: Adding polymorphic_value to boost
From: THOMAS JORDAN (tomjordan766_at_[hidden])
Date: 2017-11-20 12:28:36


On 19 November 2017 at 23:41, <boost-request_at_[hidden]> wrote:

>
> Message: 12
> Date: Mon, 20 Nov 2017 01:41:10 +0200
> From: "Peter Dimov" <lists_at_[hidden]>
> To: <boost_at_[hidden]>
> Subject: Re: [boost] Adding polymorphic_value to boost
> Message-ID: <E0D82A60493A491CBFFD0E264E3917D1_at_pdimov5>
> Content-Type: text/plain; format=flowed; charset="iso-8859-1";
> reply-type=original
>
> 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 believe I've seen other libraries (maybe Optional) provide the helpful
comment above accessors used like this to the effect that 'this accessor
syntax does not imply pointer semantics.'
I guess -> and * accessors would not be required if there was such as thing
as overloaded dot operator.


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