diff --git a/stl/inc/ranges b/stl/inc/ranges index 3ab6d3d2d1..6f71cccaa4 100644 --- a/stl/inc/ranges +++ b/stl/inc/ranges @@ -5248,8 +5248,8 @@ namespace ranges { requires input_range<_Vw> class chunk_view : public view_interface> { private: - /* [[no_unique_address]] */ _Vw _Range{}; - range_difference_t<_Vw> _Count = 0; + /* [[no_unique_address]] */ _Vw _Range; + range_difference_t<_Vw> _Count; range_difference_t<_Vw> _Remainder = 0; _Non_propagating_cache> _Current{}; @@ -5431,10 +5431,6 @@ namespace ranges { }; public: - // clang-format off - chunk_view() requires default_initializable<_Vw> = default; - // clang-format on - constexpr explicit chunk_view(_Vw _Range_, const range_difference_t<_Vw> _Count_) noexcept( is_nothrow_move_constructible_v<_Vw>) /* strengthened */ : _Range(_STD move(_Range_)), _Count{_Count_} { @@ -5478,8 +5474,8 @@ namespace ranges { requires forward_range<_Vw> class chunk_view<_Vw> : public view_interface> { private: - /* [[no_unique_address]] */ _Vw _Range{}; - range_difference_t<_Vw> _Count = 0; + /* [[no_unique_address]] */ _Vw _Range; + range_difference_t<_Vw> _Count; template class _Iterator { @@ -5691,10 +5687,6 @@ namespace ranges { }; public: - // clang-format off - chunk_view() requires default_initializable<_Vw> = default; - // clang-format on - constexpr explicit chunk_view(_Vw _Range_, const range_difference_t<_Vw> _Count_) noexcept( is_nothrow_move_constructible_v<_Vw>) /* strengthened */ : _Range(_STD move(_Range_)), _Count{_Count_} { @@ -5819,8 +5811,8 @@ namespace ranges { requires view<_Vw> class slide_view : public _Cached_position_t, _Vw, slide_view<_Vw>> { private: - /* [[no_unique_address]] */ _Vw _Range{}; - range_difference_t<_Vw> _Count = 0; + /* [[no_unique_address]] */ _Vw _Range; + range_difference_t<_Vw> _Count; template class _Iter_base {}; @@ -6053,10 +6045,6 @@ namespace ranges { }; public: - // clang-format off - slide_view() requires default_initializable<_Vw> = default; - // clang-format on - constexpr explicit slide_view(_Vw _Range_, const range_difference_t<_Vw> _Count_) noexcept( is_nothrow_move_constructible_v<_Vw>) /* strengthened */ : _Range(_STD move(_Range_)), _Count{_Count_} {} diff --git a/tests/std/tests/P2442R1_views_chunk/test.cpp b/tests/std/tests/P2442R1_views_chunk/test.cpp index 95b9b86d23..a243543ede 100644 --- a/tests/std/tests/P2442R1_views_chunk/test.cpp +++ b/tests/std/tests/P2442R1_views_chunk/test.cpp @@ -35,6 +35,10 @@ constexpr bool test_one(Rng&& rng, Expected&& expected) { STATIC_ASSERT(forward_range == forward_range); STATIC_ASSERT(bidirectional_range == bidirectional_range); STATIC_ASSERT(random_access_range == random_access_range); + + // Validate non-default-initializability + STATIC_ASSERT(!is_default_constructible_v); + // Validate borrowed_range STATIC_ASSERT(ranges::borrowed_range == (ranges::borrowed_range && forward_range) ); @@ -59,6 +63,8 @@ constexpr bool test_one(Rng&& rng, Expected&& expected) { using RC = chunk_view&>>; constexpr bool is_noexcept = !is_view || is_nothrow_copy_constructible_v; + STATIC_ASSERT(!is_default_constructible_v); + STATIC_ASSERT(same_as); STATIC_ASSERT(noexcept(views::chunk(as_const(rng), 2)) == is_noexcept); @@ -72,6 +78,8 @@ constexpr bool test_one(Rng&& rng, Expected&& expected) { using RS = chunk_view>>; constexpr bool is_noexcept = is_nothrow_move_constructible_v; + STATIC_ASSERT(!is_default_constructible_v); + STATIC_ASSERT(same_as); STATIC_ASSERT(noexcept(views::chunk(move(rng), 2)) == is_noexcept); diff --git a/tests/std/tests/P2442R1_views_slide/test.cpp b/tests/std/tests/P2442R1_views_slide/test.cpp index 2f2ad25b22..3da81edc29 100644 --- a/tests/std/tests/P2442R1_views_slide/test.cpp +++ b/tests/std/tests/P2442R1_views_slide/test.cpp @@ -39,6 +39,9 @@ constexpr bool test_one(Rng&& rng, Expected&& expected) { STATIC_ASSERT(bidirectional_range == bidirectional_range); STATIC_ASSERT(random_access_range == random_access_range); + // Validate non-default-initializability + STATIC_ASSERT(!is_default_constructible_v); + // Validate borrowed_range static_assert(ranges::borrowed_range == ranges::borrowed_range); @@ -63,6 +66,8 @@ constexpr bool test_one(Rng&& rng, Expected&& expected) { using RC = slide_view&>>; constexpr bool is_noexcept = !is_view || is_nothrow_copy_constructible_v; + STATIC_ASSERT(!is_default_constructible_v); + STATIC_ASSERT(same_as); STATIC_ASSERT(noexcept(views::slide(as_const(rng), 4)) == is_noexcept); @@ -76,6 +81,8 @@ constexpr bool test_one(Rng&& rng, Expected&& expected) { using RS = slide_view>>; constexpr bool is_noexcept = is_nothrow_move_constructible_v; + STATIC_ASSERT(!is_default_constructible_v); + STATIC_ASSERT(same_as); STATIC_ASSERT(noexcept(views::slide(move(rng), 4)) == is_noexcept);