Boost logo

Boost :

Subject: Re: [boost] Formal Review Request: TypeErasure
From: Dave Abrahams (dave_at_[hidden])
Date: 2012-06-14 20:25:23


on Thu Jun 14 2012, Julien Nitard <julien.nitard-AT-m4tp.org> wrote:

> Hi again,
>
> On Thu, Jun 14, 2012 at 2:45 AM, Dave Abrahams <dave_at_[hidden]>
>
> [...]
>
>>
>>> Moreover, when using polymorphic value types implemented this way, you
>>> are still paying for one dynamic allocation and one deletion per copy
>>> of the object (this may be implementation–specific). Since those
>>> objects are supposed to be copied frequently,
>>
>> Says who?
>
> Well, if you go all that way to have polymorphism on value types and
> you take references to them, I fail to see why you did the effort in
> the first place. You actually said:
>
>>>> and => reference semantics (- hard to reason about)
>
> I am probably missing the point, but I am not sure where.

Yes. It's a small but important distinction. Value types with
polymorphic behavior are meant to have proper copy semantics, but that
doesn't necessarily mean you're expected to copy them "frequently." In
general, you should avoid copying anything frequently.

-- 
Dave Abrahams
BoostPro Computing
http://www.boostpro.com

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