Boost logo

Boost :

Subject: Re: [boost] boost::algorithm::trim_copy() behaves like "strdup" in normal C, does it allocate a new string ?
From: Jeroen Habraken (vexocide_at_[hidden])
Date: 2012-03-10 09:49:23


On 10 March 2012 13:58, Olaf van der Spek <ml_at_[hidden]> wrote:
> On Sat, Mar 10, 2012 at 12:19 PM, Lars Viklund <zao_at_[hidden]> wrote:
>> On Fri, Mar 09, 2012 at 07:14:24PM +0100, g.fanini_at_[hidden] wrote:
>>> Could I ask for a clarification whether boost::algorithm::trim_copy()
>>> behaves like "strdup" in normal C, i.e. does it allocate a new string ? or
>>> does it modify the passed string without allocating a new string ?
>>
>> As the parameter is const, it cannot cast the const away to mutate it
>> unless it knows things about the argument at the call site, which it
>> cannot know.
>
> Hmm, wouldn't a by-value parameter allow one to avoid the copy?

Have a look at http://cpp-next.com/archive/2009/08/want-speed-pass-by-value/.

>> Also, you're using very ancient documentation there, are you really on
>> 1.34 or just using the wrong documentation?
>
> It's still the first hit on google...
>
> --
> Olaf
>
> _______________________________________________
> Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost

Jeroen


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