Boost logo

Boost :

From: Andrzej Krzemienski (akrzemi1_at_[hidden])
Date: 2019-12-05 09:00:41


śr., 4 gru 2019 o 23:33 Emil Dotchevski via Boost <boost_at_[hidden]>
napisał(a):

> This is my review of the proposed fixed_string library.
>
>
> - There was a discussion on whether or not resize should call
> boost::throw_exception. It should (as it does) because A) buffer
> overruns
> are gnarly and B) the overhead of the check is negligible, considering
> this
> is supposed to be a universal library.
>
> - Operator+ should be provided. I'm not sure whether it should use
> capacity N+M or something else, but all technical questions
> notwithstanding, users ought to be able to concatenate strings easily,
> e.g.
> if I want to add a "ms" to a number I shouldn't be jumping through
> hoops.
>

One possibility here, assuming that
* concatenating fixed_string<N> with std::string is out of the question and
* fixed_string<N> is a drop-in replacement for std::string and
* resizing over capacity is treated as a correct (albeit rare) situation in
the program

is to simply provide `fixed_string<N> operator+(fixed_string<N>,
fixed_string<N>)`.
This will be useful when some part of the program uses all `fixed_string`s
with the same capacity anyway. If fixed_string is a drop-in replacement for
string one would not be surprised with this signature.
For std::string, one is not surprised if string a was able to store its
contents, and b was able to store its contents, but there was no room to
store the concatenated version of a and b and this resulted in an exception.

Regards,
&rzej;


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