Boost logo

Boost :

Subject: Re: [boost] Variadic append for std::string
From: Christof Donat (cd_at_[hidden])
Date: 2017-01-25 12:44:33


Hi,

Am 25.01.2017 18:37, schrieb Richard Hodges:
>> The string factories, of course need more than only begin() and end().
>> They also have to provide a way to estimate the size of the output,
>> because
>> we want to be able to allocate the complete buffer upfront. In the
>> naive
>> implementation I called that size().
>
> If you have size(), it means you know the size because the conversion
> work
> has already been done.

I think, it is fine, if it returns a reasonable upper bound, like e.g. 4
for a 16 bit value in hex representation. It is just meant, to make
sure, that we can allocate enough memory upfront, and avoid calls to
realloc().

Christof


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