Boost logo

Boost :

Subject: Re: [boost] [scope_exit] can MSVC lambdas capture data members?
From: lcaminiti (lorcaminiti_at_[hidden])
Date: 2012-03-16 16:40:34


Mathias Gaunard-2 wrote
>
> On 16/03/12 20:50, lcaminiti wrote:
>>
>> Mathias Gaunard-2 wrote
>>>
>>> On 15/03/12 20:21, lcaminiti wrote:
>>>
>>>> 1) I'd propose to never implement BOOST_SCOPE_EXIT using lambdas. There
>>>> is
>>>> no advantage for the user in the lambda implementation
>>>
>>> What about
>>> 1) compile-time speed
>>> 2) run-time efficiency
>>>
>>> Aren't both of those better with lambdas?
>>>
>>
>> Bases on my LocalFunction benchmarking:
>> https://svn.boost.org/svn/boost/trunk/libs/local_function/doc/html/boost_localfunction/Alternatives.html
>>
>> I'd expect ScopeExit with lambdas to be only marginally if at all faster
>> than ScopeExit without lambas for both compile and run time. But I must
>> confess that I didn't directly benchmark ScopeExit with and without
>> lambdas
>> so I could be mistaken.
>
> Doesn't the use of C++11 remove all the ugly virtual stuff?
>

No, the "virtual stuff" is used by LocalFuncttion* to pass local classes as
template parameters but it is not required at all by ScopeExit.

(*) Note: A static member function and a static_cast were used at the end
instead of the "virtual stuff" because faster. On C++11, neither of this
trick is needed because local classes can be passed as template parameters
but not because of lambdas which are not used by LocalFunction.

Thanks,
--Lorenzo

--
View this message in context: http://boost.2283326.n4.nabble.com/boost-scope-exit-can-MSVC-lambdas-capture-data-members-tp4472788p4479306.html
Sent from the Boost - Dev mailing list archive at Nabble.com.

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