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 LWG-4013 lazy_split_view::outer-iterator::value_type should not provide default constructor #4530

Merged
merged 3 commits into from
Mar 28, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
7 changes: 4 additions & 3 deletions stl/inc/ranges
Original file line number Diff line number Diff line change
Expand Up @@ -4702,12 +4702,13 @@ namespace ranges {
private:
/* [[no_unique_address]] */ _Outer_iter _First{};

public:
value_type() = default;
constexpr explicit value_type(_Outer_iter _First_) noexcept(
is_nothrow_move_constructible_v<_Outer_iter>) // strengthened
is_nothrow_move_constructible_v<_Outer_iter>)
: _First{_STD move(_First_)} {}

friend _Outer_iter;

public:
_NODISCARD constexpr auto begin() const {
return _Inner_iter<_Const>{_First};
}
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 @@ -165,6 +165,10 @@ std/utilities/memory/specialized.algorithms/uninitialized.fill.n/ranges_uninitia
std/utilities/memory/specialized.algorithms/uninitialized.move/ranges_uninitialized_move.pass.cpp FAIL
std/utilities/memory/specialized.algorithms/uninitialized.move/ranges_uninitialized_move_n.pass.cpp FAIL

# libc++ doesn't implement LWG-4013
std/ranges/range.adaptors/range.lazy.split/range.lazy.split.outer.value/ctor.default.pass.cpp FAIL
std/ranges/range.adaptors/range.lazy.split/range.lazy.split.outer.value/ctor.iter.pass.cpp FAIL

# If any feature-test macro test is failing, this consolidated test will also fail.
std/language.support/support.limits/support.limits.general/version.version.compile.pass.cpp FAIL

Expand Down
16 changes: 16 additions & 0 deletions tests/std/tests/P0896R4_views_lazy_split/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ constexpr void test_one(Base&& base, Delimiter&& delimiter, Expected&& expected)

STATIC_ASSERT(same_as<decltype(base | closure), R>);
STATIC_ASSERT(noexcept(base | closure) == is_noexcept);

using outer_iterator = decltype(views::lazy_split(base, delimiter).begin());
STATIC_ASSERT(!is_default_constructible_v<iter_value_t<outer_iterator>>); // LWG-4013
STATIC_ASSERT(!is_constructible_v<iter_value_t<outer_iterator>, outer_iterator>); // LWG-4013
}

// ... with const lvalue argument
Expand All @@ -77,6 +81,10 @@ constexpr void test_one(Base&& base, Delimiter&& delimiter, Expected&& expected)

STATIC_ASSERT(same_as<decltype(as_const(base) | closure), R>);
STATIC_ASSERT(noexcept(as_const(base) | closure) == is_noexcept);

using outer_iterator = decltype(views::lazy_split(as_const(base), delimiter).begin());
STATIC_ASSERT(!is_default_constructible_v<iter_value_t<outer_iterator>>); // LWG-4013
STATIC_ASSERT(!is_constructible_v<iter_value_t<outer_iterator>, outer_iterator>); // LWG-4013
} else if constexpr (!is_view) {
using LSV = ranges::lazy_split_view<ranges::ref_view<const remove_reference_t<Base>>, DV>;
constexpr bool is_noexcept = is_nothrow_constructible_v<LSV, const remove_reference_t<Base>&, Delimiter&>;
Expand All @@ -99,6 +107,10 @@ constexpr void test_one(Base&& base, Delimiter&& delimiter, Expected&& expected)

STATIC_ASSERT(same_as<decltype(move(base) | closure), R>);
STATIC_ASSERT(noexcept(move(base) | closure) == is_noexcept);

using outer_iterator = decltype(views::lazy_split(move(base), delimiter).begin());
STATIC_ASSERT(!is_default_constructible_v<iter_value_t<outer_iterator>>); // LWG-4013
STATIC_ASSERT(!is_constructible_v<iter_value_t<outer_iterator>, outer_iterator>); // LWG-4013
} else if constexpr (movable<remove_reference_t<Base>>) {
using RS = ranges::lazy_split_view<ranges::owning_view<remove_reference_t<Base>>, DV>;
constexpr bool is_noexcept =
Expand All @@ -123,6 +135,10 @@ constexpr void test_one(Base&& base, Delimiter&& delimiter, Expected&& expected)

STATIC_ASSERT(same_as<decltype(move(as_const(base)) | closure), R>);
STATIC_ASSERT(noexcept(move(as_const(base)) | closure) == is_noexcept);

using outer_iterator = decltype(views::lazy_split(move(as_const(base)), delimiter).begin());
STATIC_ASSERT(!is_default_constructible_v<iter_value_t<outer_iterator>>); // LWG-4013
STATIC_ASSERT(!is_constructible_v<iter_value_t<outer_iterator>, outer_iterator>); // LWG-4013
}

// Validate deduction guide
Expand Down