Boost logo

Boost :

Subject: Re: [boost] [review] Convert library
From: Vladimir Batov (vb.mail.247_at_[hidden])
Date: 2014-05-26 05:33:21


Andrzej Krzemienski wrote
> 2014-05-26 11:08 GMT+02:00 Vladimir Batov <

> vb.mail.247@

> >:
>> ...
>> I do not see Andrzej confirming anything. He indeed asked a question...
>> which a far from a confirmation of any sort. The way I see it
>>
>> user-level
>> optional
> <T>
> res = convert
> <T>
> (from, cnv);
>>
>> the standard optimization/elision mechanism is to pass "res" to
>> convert().
>> So, it becomes
>>
>> convert(optional
> <T>
> & res, from, cnv);
>
> I claim (without evidence in form of benchmarks) that returning optional
> <T>
> by value should not be slower than passing it as an input argument. Most
> compilers elide the moves/copies today, don't they? I would recommend
> making measurements before applying this optimization.

Andrzej, you are correct... and I am not suggesting to change the signature.
The change from user-friendly

    optional<T> res = convert<T>(from, cnv);

to

    convert(optional<T>& res, from, cnv);

is done by the compiler as part of optimization/elision. That technique's
been around for many years. I won't be surprised if optimization is far
trickier than that these days.

--
View this message in context: http://boost.2283326.n4.nabble.com/review-Convert-library-tp4662821p4662891.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