Boost logo

Boost :

From: Marshall Clow (mclow.lists_at_[hidden])
Date: 2022-05-11 04:15:19


On May 10, 2022, at 8:35 PM, Klemens Morgenstern via Boost <boost_at_[hidden]> wrote:
>
> Hi y'all,
>
> I've hacked together a cstring_view class and would like to ask if it
> could be included in boost.utility or boost.core.
>
> https://gist.github.com/klemens-morgenstern/fc02dab8b37fc77ac80efbca30f297cf
>
> The main motivation is to have a view that works with C-APIs. I also
> need the char_traits for dealing with odd char semantics for some
> system APIs. (e.g. environment keys on windows are char-insensitive but
> preserving).

I don’t see how this is supposed to maintain the invariant ( null temination) w/o it’s own storage.

Consider:
    cstring_view sv; // is sv-data() pointing to a null-terminated string? If so, where did it come from?

    cstring_view sv1(“abcdefg”)’
    sv1.substring(3, 2); // what’s the value of strlen(sv.data) here? How can it be 2?

— Marshall


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