C++ Logo

sg16

Advanced search

Re: [isocpp-sg16] Agenda for the 2025-04-09 SG16 meeting

From: Peter Bindels <peterbindels_at_[hidden]>
Date: Wed, 9 Apr 2025 21:21:51 +0200
On Wed, Apr 9, 2025 at 9:17 PM Nevin Liber via SG16 <sg16_at_[hidden]>
wrote:

> On Wed, Apr 9, 2025 at 1:18 PM Tom Honermann via SG16 <
> sg16_at_[hidden]> wrote:
>
>> Section 6.1 (zstring_view and string_view relation) of P3655R0
>> <https://wg21.link/p3655r0#zstring_view-and-string_view-relation>
>> concludes that std::zstring_view can't be implemented in terms of
>> std::string_view. I'm not yet convinced that is correct though.
>>
>
> Me neither. In section 6.1 I don't quite understand how: "there can not
> be an inheritance relation between the two" follows from "in particular it
> is not well-formed to use string_view's operator= to assign a
> non-null-terminated string_view to a zstring_view". If we use inheritance,
> assigning a zstring_view from a string_view doesn't compile anyway when
> we default operator=. I'm not seeing the problem here.
>

You can convert a zstring_view& to a string_view& in that case.

You can assign a non-null-terminated string_view to that reference.

The zstring_view that contains that string_view now no longer holds its
invariants.

Received on 2025-04-09 19:22:04