Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement P2499R0: string_view Range Constructor Should Be explicit #2947

Merged
merged 5 commits into from
Jul 28, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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