Boost logo

Boost :

From: Andrey Semashev (andrey.semashev_at_[hidden])
Date: 2019-09-14 06:15:43

On 2019-09-14 02:19, Vinnie Falco via Boost wrote:
> On Fri, Sep 13, 2019, 3:58 PM Ion Gaztañaga via Boost <boost_at_[hidden]>
> wrote:
>> On 13/09/2019 14:43, Vinnie Falco via Boost wrote:
>>> On Fri, Sep 13, 2019 at 3:28 AM <> wrote:
>>>> Why not use a static_vector<char> ?
>>> static_vector is missing all of the string-oriented algorithms.
>>>> There is a cost associated with maintaining the null termination of
>> strings
>>> Yeah, that's easily fixed. We can add the function
>>> fixed_capacity_string::c_str() which will put the terminator on and
>>> return a pointer, this way the mutating operations do not need to
>>> always leave the string in a null terminated state.
>> But then c_str() would not be "const noexcept".
> Is that a big deal? I dont think so
> ...

It is. Obtaining C-style string without exceptions is important e.g. in
exception::what(). It is also not uncommon to want to process strings in
a non-throwing fashion involving C standard library, and it requires
null-terminated strings. Also note that c_str() is an observer, which is
supposed to not modify the string (IOW must be callable on a const
string). In general, I see throwing and mutating c_str() as a major
hinderance. C-style strings are still wide-spead, regardless of how much
we love string_view.

Boost list run by bdawes at, gregod at, cpdaniel at, john at