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 12:36:56


On 6/11/2010 12:27 PM, David Abrahams wrote:
> At Fri, 11 Jun 2010 12:12:27 -0400,
>>
>> That gives us an opportunity to add a new feature to Phoenix: default
>> capture modes. I could see something like:
>>
>> ref[ phoenix-lambda-expression ]
>>
>> makes default capture by-ref, and
>>
>> val[ phoenix-lambda-expression ]
>
> I would be cautious about emulating C++0x lambdas. I'm not sure yet
> that they don't suck.

They suck, but not for this reason. ;-)

>> 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.

>>> why not perfect forwarding?
>>
>> Because it's too expensive to simulate in C++98.
>
> Oh, I meant for 0x. Be cautious, also, about designing for C++98 at
> the expense of a good 0x interface.

Agreed in principle, but I don't think we have much choice at this
point. We want Phoenix to be usable today. How long will it before we
can reasonably assume everyone doing C++ has variadics and rvalue refs?
A long time, I think. As a compromise, we can put the variadic/rvalue
ref implementation on a switch and let users opt in if they have the
features and don't care about portability.

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