diff --git a/libcxx/docs/Status/Cxx2bIssues.csv b/libcxx/docs/Status/Cxx2bIssues.csv --- a/libcxx/docs/Status/Cxx2bIssues.csv +++ b/libcxx/docs/Status/Cxx2bIssues.csv @@ -272,7 +272,7 @@ "`3850 `__","``views::as_const`` on ``empty_view`` should return ``empty_view``","February 2023","","","|ranges|" "`3851 `__","``chunk_view::inner-iterator`` missing custom ``iter_move`` and ``iter_swap``","February 2023","","","|ranges|" "`3853 `__","``basic_const_iterator::operator->`` is ill-formed","February 2023","","","" -"`3857 `__","``basic_string_view`` should allow explicit conversion when only traits vary","February 2023","","","" +"`3857 `__","``basic_string_view`` should allow explicit conversion when only traits vary","February 2023","|Complete|","17.0","" "`3860 `__","``range_common_reference_t`` is missing","February 2023","","","|ranges|" "`3866 `__","Bad Mandates for ``expected::transform_error`` overloads","February 2023","","","" "`3867 `__","Should ``std::basic_osyncstream``'s move assignment operator be ``noexcept``?","February 2023","","","" diff --git a/libcxx/include/string_view b/libcxx/include/string_view --- a/libcxx/include/string_view +++ b/libcxx/include/string_view @@ -323,10 +323,7 @@ !is_convertible_v<_Range, const _CharT*> && (!requires(remove_cvref_t<_Range>& __d) { __d.operator _VSTD::basic_string_view<_CharT, _Traits>(); - }) && - (!requires { - typename remove_reference_t<_Range>::traits_type; - } || is_same_v::traits_type, _Traits>) + }) ) constexpr explicit _LIBCPP_HIDE_FROM_ABI basic_string_view(_Range&& __r) : __data_(ranges::data(__r)), __size_(ranges::size(__r)) {} diff --git a/libcxx/test/std/strings/string.view/string.view.cons/from_range.pass.cpp b/libcxx/test/std/strings/string.view/string.view.cons/from_range.pass.cpp --- a/libcxx/test/std/strings/string.view/string.view.cons/from_range.pass.cpp +++ b/libcxx/test/std/strings/string.view/string.view.cons/from_range.pass.cpp @@ -20,7 +20,6 @@ #include #include -#include "constexpr_char_traits.h" #include "make_string.h" #include "test_iterators.h" #include "test_range.h" @@ -107,6 +106,15 @@ assert(sv == "test"); } + // Different trait types + { + struct OtherTraits : std::char_traits {}; + std::basic_string_view sv1{"hello"}; + std::basic_string_view sv2(sv1); + assert(sv1.size() == sv2.size()); + assert(sv1.data() == sv2.data()); + } + return true; } @@ -135,25 +143,7 @@ static_assert(std::is_constructible_v); // lvalue static_assert(std::is_constructible_v); // const lvalue -static_assert(std::is_constructible_v); // rvalue - -template -struct WithTraitsType { - typename CharTraits::char_type* begin() const; - typename CharTraits::char_type* end() const; - using traits_type = CharTraits; -}; - -using CCT = constexpr_char_traits; -static_assert(std::is_constructible_v>>); -#ifndef TEST_HAS_NO_WIDE_CHARACTERS -static_assert(std::is_constructible_v>>); -#endif -static_assert(std::is_constructible_v, WithTraitsType>); -static_assert(!std::is_constructible_v>); // wrong traits type -#ifndef TEST_HAS_NO_WIDE_CHARACTERS -static_assert(!std::is_constructible_v>>); // wrong traits type -#endif +static_assert(std::is_constructible_v); // rvalue #ifndef TEST_HAS_NO_EXCEPTIONS void test_throwing() { diff --git a/libcxx/test/std/strings/string.view/string.view.cons/from_string1.compile.fail.cpp b/libcxx/test/std/strings/string.view/string.view.cons/from_string1.compile.fail.cpp deleted file mode 100644 --- a/libcxx/test/std/strings/string.view/string.view.cons/from_string1.compile.fail.cpp +++ /dev/null @@ -1,34 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -// UNSUPPORTED: !stdlib=libc++ && (c++03 || c++11 || c++14) - -// - -// template -// basic_string_view(const basic_string<_CharT, _Traits, Allocator>& _str) noexcept - -#include -#include -#include - -struct dummy_char_traits : public std::char_traits {}; - -int main(int, char**) { - using string_view = std::basic_string_view; - using string = std:: basic_string ; - - { - string s{"QBCDE"}; - string_view sv1 ( s ); - assert ( sv1.size() == s.size()); - assert ( sv1.data() == s.data()); - } - - return 0; -} diff --git a/libcxx/test/std/strings/string.view/string.view.cons/from_string2.compile.fail.cpp b/libcxx/test/std/strings/string.view/string.view.cons/from_string2.compile.fail.cpp deleted file mode 100644 --- a/libcxx/test/std/strings/string.view/string.view.cons/from_string2.compile.fail.cpp +++ /dev/null @@ -1,34 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -// UNSUPPORTED: !stdlib=libc++ && (c++03 || c++11 || c++14) - -// - -// template -// basic_string_view(const basic_string<_CharT, _Traits, Allocator>& _str) noexcept - -#include -#include -#include - -struct dummy_char_traits : public std::char_traits {}; - -int main(int, char**) { - using string_view = std::basic_string_view; - using string = std:: basic_string ; - - { - string s{"QBCDE"}; - string_view sv1 ( s ); - assert ( sv1.size() == s.size()); - assert ( sv1.data() == s.data()); - } - - return 0; -}