diff --git a/stl/inc/xutility b/stl/inc/xutility index f1f33652ce..3a0592c74c 100644 --- a/stl/inc/xutility +++ b/stl/inc/xutility @@ -2893,7 +2893,7 @@ namespace ranges { template _NODISCARD _MSVC_INTRINSIC constexpr auto& _Possibly_const_range(_Rng& _Range) noexcept { - if constexpr (constant_range && !constant_range<_Rng>) { + if constexpr (input_range) { return _STD as_const(_Range); } else { return _Range; diff --git a/tests/std/tests/P0896R4_views_join/test.cpp b/tests/std/tests/P0896R4_views_join/test.cpp index d909d97b9c..2e14c10816 100644 --- a/tests/std/tests/P0896R4_views_join/test.cpp +++ b/tests/std/tests/P0896R4_views_join/test.cpp @@ -269,7 +269,7 @@ constexpr bool test_one(Outer&& rng, Expected&& expected) { static_assert(CanMemberCEnd == (forward_range && is_reference_v> && input_range>) ); - const same_as> auto cs = r.end(); + const auto cs = r.end(); if (!is_empty) { if constexpr (bidirectional_range && common_range) { assert(*prev(cs) == *prev(end(expected))); diff --git a/tests/std/tests/P0896R4_views_lazy_split/test.cpp b/tests/std/tests/P0896R4_views_lazy_split/test.cpp index e2aa5b8664..6900be50a8 100644 --- a/tests/std/tests/P0896R4_views_lazy_split/test.cpp +++ b/tests/std/tests/P0896R4_views_lazy_split/test.cpp @@ -359,6 +359,14 @@ constexpr bool test_lwg_3904() { return j != r.end(); } +void test_lwg_4027() { // COMPILE-ONLY + auto r = views::single(0) | views::lazy_split(0); + using R1 = decltype((*ranges::cbegin(r)).front()); + using R2 = decltype((*cbegin(r)).front()); + static_assert(same_as); + static_assert(is_const_v>); +} + int main() { static_assert(instantiation_test()); instantiation_test(); diff --git a/tests/std/tests/P0896R4_views_transform/test.cpp b/tests/std/tests/P0896R4_views_transform/test.cpp index eb2c729102..4c543fa6db 100644 --- a/tests/std/tests/P0896R4_views_transform/test.cpp +++ b/tests/std/tests/P0896R4_views_transform/test.cpp @@ -879,6 +879,13 @@ void test_gh_3014() { // COMPILE-ONLY [[maybe_unused]] decltype(as_const(r).begin()) i = r.begin(); // Check 'iterator(iterator i)' } +void test_lwg_4027() { // COMPILE-ONLY + auto r = views::single(0) | views::transform([](int) { return 0; }); + using CIt1 = decltype(ranges::cbegin(r)); + using CIt2 = decltype(cbegin(r)); + static_assert(same_as); +} + int main() { { // Validate copyable views constexpr span s{some_ints}; diff --git a/tests/std/tests/P2278R4_ranges_const_range_machinery/test.cpp b/tests/std/tests/P2278R4_ranges_const_range_machinery/test.cpp index 30583ee42f..fe49cd330f 100644 --- a/tests/std/tests/P2278R4_ranges_const_range_machinery/test.cpp +++ b/tests/std/tests/P2278R4_ranges_const_range_machinery/test.cpp @@ -127,8 +127,8 @@ namespace test_prvalue_range { static_assert(CanRangeConstIterator); static_assert(CanRangeConstSentinel); static_assert(CanRangeConstReference); - static_assert(same_as, const_iterator>>); - static_assert(same_as, const_iterator>>); + static_assert(!same_as, const_iterator>>); + static_assert(!same_as, const_iterator>>); static_assert(same_as, int>); static_assert(ranges::constant_range);