Boost logo

Boost :

Subject: Re: [boost] [GSoC][Phoenix3] Regarding mutability of arguments passed to phoenix expressions
From: Eric Niebler (eric_at_[hidden])
Date: 2010-06-11 13:03:00


On 6/11/2010 12:36 PM, Eric Niebler wrote:
> On 6/11/2010 12:27 PM, David Abrahams wrote:
>> At Fri, 11 Jun 2010 12:12:27 -0400, Eric Niebler wrote
>
>>> makes it by-val. Under the hood, Phoenix would actually be storing every
>>> captured variable both by value and by reference.
>>
>> !! Sounds expensive.
>
> The plan has always been to make capture-by-value the default. Saving
> off a reference as well is free.

Well, there's a hitch.

  ref[ bigobj += _1 ]

Users might reasonably expect this to not make a copy of bigobj, and the
way to avoid it is not obvious:

  ref[ ref(bigobj) += _1 ]

Clearly the user has already stated their intention to capture bigobj by
reference and shouldn't have to say it again.

I think default capture modes may be unworkable if we want the default
mode to be by-value.

-- 
Eric Niebler
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