C++ Logo


Advanced search

Re: Avoid copies when using string_view with APIs expecting null terminated strings

From: Thiago Macieira <thiago_at_[hidden]>
Date: Sun, 27 Dec 2020 10:02:20 -0300
On Sunday, 27 December 2020 05:34:55 -03 Nikolay Mihaylov via Std-Proposals
> ... the point is...
> stealing bits from pointer is not portable, even between compilers. I know
> it can be done for x64 and probably Arm 64, but for Arm32 or 32 bit Intel -
> I am not sure.

That is QoI. We don't need to discuss *how* an implementation will do it. The
standard only concerns itself with behaviour.

My point is only that there are ways, some better than others, but none of
them have zero cost. And that is the crux of the issue, even if the ABI were
not a concern. The cost/benefit ratio needs to be justified, because it's
something all users of string_view would need to pay.

Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
   Software Architect - Intel DPG Cloud Engineering

Received on 2020-12-27 07:02:26