C++ Logo

STD-PROPOSALS

Advanced search

Subject: Re: [std-proposals] Avoid copies when using string_view with APIs expecting null terminated strings
From: Jason McKesson (jmckesson_at_[hidden])
Date: 2020-12-23 15:58:13


On Wed, Dec 23, 2020 at 5:17 AM Tom Mason via Std-Proposals
<std-proposals_at_[hidden]> wrote:
>
> I do think it's useful to use the one type.

I didn't say it couldn't be useful. But the ABI breakage it would
cause (adding more information to `string_view`, thus making it
bigger) is not worth it. And I would argue that the few cases where it
might be better to carry both a size and whether the string is
NUL-terminated aren't worth having any type carry around both of those
pieces of information. The tradeoff just isn't worth it.

Having a type dedicated to being specifically a view into a
NUL-terminated string solves most of the problems, and does so in a
way that makes it clear what your API needs.


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

Standard Proposals Archives on Google Groups