Boost logo

Boost :

Subject: Re: [boost] [algorithm] to_lower_copy / to_upper_copy with no output param assumes sequence to be same as input
From: Sebastian Karlsson (sairony_at_[hidden])
Date: 2011-06-23 15:42:43


2011/6/23 Olaf van der Spek <ml_at_[hidden]>:
> On Thu, Jun 23, 2011 at 1:26 PM, Sebastian Karlsson <sairony_at_[hidden]> wrote:
>>>>                        OutputSequenceT Output( ::boost::begin( Input ), ::boost::end( Input ) );
>>>
>>> Doesn't this also do an unnecessary copy?
>>>
>>> Olaf
>>
>> It does, but it uses one less which as stated is a prime candidate for
>> NRVO. The current approach needs one temporary for the return value as
>> well as a temporary for argument conversion, which is basically only
>> there to inform about the return type.
>
> OutputSequenceT Output( ::boost::begin( Input ), ::boost::end( Input ) );
>
> This one copies input to output. Then the function does case conversion.
> The original (AFAIK) does the case conversion while copying from input
> to output.
>
> Olaf

That appears to be truth, that's only a flaw in my implementation
though, I'll see if I can fix it :)

Kind regards,
Sebastian Karlsson


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