From 45ca314616f3877e3d6ff4323815bbcf691c6330 Mon Sep 17 00:00:00 2001 From: cpplearner Date: Fri, 15 Dec 2023 16:21:38 +0800 Subject: [PATCH 1/2] Make join_view and join_with_view iterators default-constructible --- stl/inc/ranges | 8 ++------ tests/std/tests/P0896R4_views_join/test.cpp | 10 ++++++++++ tests/std/tests/P2441R2_views_join_with/test.cpp | 10 ++++++++++ 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/stl/inc/ranges b/stl/inc/ranges index 8c76bce3d6..752daa24c1 100644 --- a/stl/inc/ranges +++ b/stl/inc/ranges @@ -3806,9 +3806,7 @@ namespace ranges { using value_type = range_value_t<_InnerRng<_Const>>; using difference_type = common_type_t, range_difference_t<_InnerRng<_Const>>>; - // clang-format off - _Iterator() requires default_initializable<_OuterIter> = default; - // clang-format on + _Iterator() = default; constexpr _Iterator(_Iterator _It) requires _Const && convertible_to, _OuterIter> @@ -4262,9 +4260,7 @@ namespace ranges { using value_type = common_type_t, iter_value_t<_PatternIter>>; using difference_type = _Common_diff_t<_OuterIter, _InnerIter, _PatternIter>; - // clang-format off - _Iterator() requires default_initializable<_OuterIter> = default; - // clang-format on + _Iterator() = default; constexpr _Iterator(_Iterator _It) requires _Const && convertible_to, _OuterIter> diff --git a/tests/std/tests/P0896R4_views_join/test.cpp b/tests/std/tests/P0896R4_views_join/test.cpp index 25c2647b76..422d1fe451 100644 --- a/tests/std/tests/P0896R4_views_join/test.cpp +++ b/tests/std/tests/P0896R4_views_join/test.cpp @@ -177,6 +177,16 @@ constexpr bool test_one(Outer&& rng, Expected&& expected) { } } + // Also validate that join_view iterators are default-constructible + { + STATIC_ASSERT(is_default_constructible_v>); + [[maybe_unused]] iterator_t i; + if constexpr (CanMemberBegin) { + STATIC_ASSERT(is_default_constructible_v>); + [[maybe_unused]] iterator_t ci; + } + } + // Validate join_view::end static_assert(CanMemberEnd); static_assert(CanMemberEnd diff --git a/tests/std/tests/P2441R2_views_join_with/test.cpp b/tests/std/tests/P2441R2_views_join_with/test.cpp index f2deb38004..994f6d9b55 100644 --- a/tests/std/tests/P2441R2_views_join_with/test.cpp +++ b/tests/std/tests/P2441R2_views_join_with/test.cpp @@ -219,6 +219,16 @@ constexpr void test_one(Outer&& rng, Delimiter&& delimiter, Expected&& expected) } } + // Also validate that join_with_view iterators are default-constructible + { + STATIC_ASSERT(is_default_constructible_v>); + [[maybe_unused]] iterator_t i; + if constexpr (CanMemberBegin) { + STATIC_ASSERT(is_default_constructible_v>); + [[maybe_unused]] iterator_t ci; + } + } + // Validate join_with_view::end static_assert(CanMemberEnd); static_assert(CanMemberEnd From babfc0f950427ffa9c93d6b5ceb9d8d3053cbcdf Mon Sep 17 00:00:00 2001 From: "S. B. Tam" Date: Sat, 16 Dec 2023 10:32:35 +0800 Subject: [PATCH 2/2] Unskip the relevant libc++ test --- tests/libcxx/expected_results.txt | 3 --- 1 file changed, 3 deletions(-) diff --git a/tests/libcxx/expected_results.txt b/tests/libcxx/expected_results.txt index aa7119f94a..5667c84ffe 100644 --- a/tests/libcxx/expected_results.txt +++ b/tests/libcxx/expected_results.txt @@ -1206,9 +1206,6 @@ std/ranges/range.adaptors/range.join/range.join.iterator/star.pass.cpp:0 FAIL # Not analyzed. constexpr evaluation fails in ranges::swap. std/ranges/range.adaptors/range.join/range.join.iterator/iter.swap.pass.cpp:0 FAIL -# Not analyzed. Fails static_assert(std::is_default_constructible_v). -std/ranges/range.adaptors/range.join/range.join.iterator/ctor.default.pass.cpp FAIL - # Not analyzed. constexpr evaluation fails in assert(element_moved == 1). std/ranges/range.adaptors/range.lazy.split/ctor.range.pass.cpp:0 FAIL std/ranges/range.adaptors/range.split/ctor.range.pass.cpp:0 FAIL