C++ Logo


Advanced search

Subject: Re: [std-proposals] Avoid copies when using string_view with APIs expecting null terminated strings
From: Arthur O'Dwyer (arthur.j.odwyer_at_[hidden])
Date: 2020-12-26 16:06:25

On Sat, Dec 26, 2020, 3:03 PM Thiago Macieira via Std-Proposals <
std-proposals_at_[hidden]> wrote:

> On Saturday, 26 December 2020 03:38:20 -03 Tony V E via Std-Proposals
> wrote:
> > An implementation can probably hide the ‎bool inside an unused bit of the
> > pointer (or length),

A third option is to use one of the unused bits in the pointer on CPUs that
> support address masking / colouring.

Storing in the integer length: almost certainly okay.
Storing in the pointer: almost certainly not okay, unless I have failed to
keep up with C++20 constexpr rules. string_view is specified to be
constexpr-friendly in C++17 and later. That means no type-punning.


STD-PROPOSALS list run by std-proposals-owner@lists.isocpp.org

Standard Proposals Archives on Google Groups