Skip to content

Commit

Permalink
Implement P2499R0: string_view Range Constructor Should Be `explici…
Browse files Browse the repository at this point in the history
…t` (#2947)
  • Loading branch information
sam20908 authored Jul 28, 2022
1 parent 06e7769 commit 6db1eb4
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion stl/inc/xstring
Original file line number Diff line number Diff line change
Expand Up @@ -1260,7 +1260,7 @@ public:
&& (!requires {
typename remove_reference_t<_Range>::traits_type;
} || same_as<typename remove_reference_t<_Range>::traits_type, _Traits>))
constexpr basic_string_view(_Range&& _Rng) noexcept(
constexpr explicit basic_string_view(_Range&& _Rng) noexcept(
noexcept(_RANGES data(_Rng)) && noexcept(_RANGES size(_Rng))) // strengthened
: _Mydata(_RANGES data(_Rng)), _Mysize(static_cast<size_t>(_RANGES size(_Rng))) {}
// clang-format on
Expand Down
1 change: 1 addition & 0 deletions stl/inc/yvals_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,7 @@
// P2441R2 views::join_with
// P2442R1 Windowing Range Adaptors: views::chunk, views::slide
// P2443R1 views::chunk_by
// P2499R0 string_view Range Constructor Should Be explicit
// P2549R0 unexpected<E>::error()

// Parallel Algorithms Notes
Expand Down
4 changes: 4 additions & 0 deletions tests/libcxx/expected_results.txt
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ std/utilities/format/format.formatter/format.parse.ctx/begin.pass.cpp FAIL
std/utilities/format/format.formatter/format.parse.ctx/ctor.pass.cpp FAIL
std/utilities/format/format.formatter/format.parse.ctx/end.pass.cpp FAIL

# libc++ doesn't yet implement P2499R0
std/strings/string.view/string.view.cons/from_range.pass.cpp FAIL
std/strings/string.view/string.view.deduct/range.pass.cpp FAIL

# libc++ doesn't correctly constrain the iterator_traits specialization for common_iterator (https://reviews.llvm.org/D117449)
std/iterators/predef.iterators/iterators.common/iterator_traits.compile.pass.cpp FAIL

Expand Down
4 changes: 4 additions & 0 deletions tests/libcxx/skipped_tests.txt
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ utilities\format\format.formatter\format.parse.ctx\begin.pass.cpp
utilities\format\format.formatter\format.parse.ctx\ctor.pass.cpp
utilities\format\format.formatter\format.parse.ctx\end.pass.cpp

# libc++ doesn't yet implement P2499R0
strings\string.view\string.view.cons\from_range.pass.cpp
strings\string.view\string.view.deduct\range.pass.cpp

# libc++ doesn't correctly constrain the iterator_traits specialization for common_iterator (https://reviews.llvm.org/D117449)
iterators\predef.iterators\iterators.common\iterator_traits.compile.pass.cpp

Expand Down
4 changes: 3 additions & 1 deletion tests/std/tests/P0220R1_string_view/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,9 @@ constexpr bool test_case_range_constructor() {

// Also tests some of the constraints:
static_assert(is_constructible_v<string_view, vector<char>>);
static_assert(is_convertible_v<vector<char>, string_view>);

// P2499R0 string_view Range Constructor Should Be explicit
static_assert(!is_convertible_v<vector<char>, string_view>);

static_assert(!is_constructible_v<string_view, deque<char>>); // not contiguous
static_assert(!is_convertible_v<deque<char>, string_view>);
Expand Down

0 comments on commit 6db1eb4

Please sign in to comment.