This is an archive of the discontinued LLVM Phabricator instance.

[libc++] LWG 3857: allow `string_view` conversion when only traits vary
ClosedPublic

Authored by jloser on Feb 13 2023, 7:17 PM.

Details

Summary

The basic_string_view constructor accepting a contiguous range rejects
converting between basic_string_view even when only the trait types vary.
This prevents conversions for converting from basic_string_view<C, T1> and
basic_string<C, T1, A> to basic_string_view<C, T2>. Recently, this
constructor was made explicit, so there's no reason to really forbid this
conversion anymore.

Relax the restriction that the trait types need to match in this constructor.

Diff Detail

Event Timeline

jloser created this revision.Feb 13 2023, 7:17 PM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 13 2023, 7:17 PM
jloser requested review of this revision.Feb 13 2023, 7:17 PM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 13 2023, 7:17 PM
Herald added a reviewer: Restricted Project. · View Herald Transcript
jloser updated this revision to Diff 497177.Feb 13 2023, 7:23 PM

Undo extra clang-format in from_range.pass.cpp

jloser added inline comments.Feb 13 2023, 7:24 PM
libcxx/test/std/strings/string.view/string.view.cons/from_range.pass.cpp
145–146

I slightly prefer ripping this (and the few lines above it) out entirely. It was originally just to model this constraint failure case. How do others feel? I've left it in for now, but it's not testing anything too useful now IMO.

philnik accepted this revision.Feb 14 2023, 1:50 AM

LGTM.

libcxx/test/std/strings/string.view/string.view.cons/from_range.pass.cpp
145–146

I think we can remove the static_asserts, since we have a runtime test now.

This revision is now accepted and ready to land.Feb 14 2023, 1:50 AM
jloser updated this revision to Diff 497325.Feb 14 2023, 7:28 AM
jloser edited the summary of this revision. (Show Details)

Drop the static_assert tests that verified traits_type mismatches as they are no longer relevant

libcxx/test/std/strings/string.view/string.view.cons/from_range.pass.cpp
145–146

SGTM — just removed them.

@Mordante do you want me to wait until you land https://reviews.llvm.org/D143845? Or, you can just feel free to mark LWG 3857 as Completed in LLVM 17.0.0 if I land this first — whatever you prefer.

jloser updated this revision to Diff 497332.Feb 14 2023, 7:51 AM
jloser edited the summary of this revision. (Show Details)

Remove unnecessary constexpr_char_traits.h include

jloser updated this revision to Diff 497354.Feb 14 2023, 9:02 AM

Rebase since the clang-format requirement patch landed

@Mordante do you want me to wait until you land https://reviews.llvm.org/D143845? Or, you can just feel free to mark LWG 3857 as Completed in LLVM 17.0.0 if I land this first — whatever you prefer.

I've landed my change, can you rebased and update the issue list before landing.

ldionne accepted this revision.Feb 15 2023, 8:57 AM

Awesome, thanks for being on top of this! LGTM w/ rebase on top of LWG issues list.

jloser updated this revision to Diff 497870.Feb 15 2023, 7:38 PM

Rebase and mark the paper status as completed

This revision was landed with ongoing or failed builds.Feb 16 2023, 5:00 AM
This revision was automatically updated to reflect the committed changes.
libcxx/test/std/strings/string.view/string.view.cons/from_range.pass.cpp