diff --git a/libcxx/include/__ranges/access.h b/libcxx/include/__ranges/access.h --- a/libcxx/include/__ranges/access.h +++ b/libcxx/include/__ranges/access.h @@ -163,11 +163,12 @@ namespace __cbegin { struct __fn { template + requires is_lvalue_reference_v<_Tp&&> [[nodiscard]] _LIBCPP_HIDE_FROM_ABI - constexpr auto operator()(_Tp& __t) const - noexcept(noexcept(ranges::begin(static_cast(__t)))) - -> decltype( ranges::begin(static_cast(__t))) - { return ranges::begin(static_cast(__t)); } + constexpr auto operator()(_Tp&& __t) const + noexcept(noexcept(ranges::begin(static_cast&>(__t)))) + -> decltype( ranges::begin(static_cast&>(__t))) + { return ranges::begin(static_cast&>(__t)); } template requires is_rvalue_reference_v<_Tp&&> @@ -190,11 +191,12 @@ namespace __cend { struct __fn { template + requires is_lvalue_reference_v<_Tp&&> [[nodiscard]] _LIBCPP_HIDE_FROM_ABI - constexpr auto operator()(_Tp& __t) const - noexcept(noexcept(ranges::end(static_cast(__t)))) - -> decltype( ranges::end(static_cast(__t))) - { return ranges::end(static_cast(__t)); } + constexpr auto operator()(_Tp&& __t) const + noexcept(noexcept(ranges::end(static_cast&>(__t)))) + -> decltype( ranges::end(static_cast&>(__t))) + { return ranges::end(static_cast&>(__t)); } template requires is_rvalue_reference_v<_Tp&&> diff --git a/libcxx/test/std/ranges/range.access/begin.pass.cpp b/libcxx/test/std/ranges/range.access/begin.pass.cpp --- a/libcxx/test/std/ranges/range.access/begin.pass.cpp +++ b/libcxx/test/std/ranges/range.access/begin.pass.cpp @@ -48,7 +48,7 @@ static_assert( std::is_invocable_v); static_assert(!std::is_invocable_v); static_assert( std::is_invocable_v); -static_assert( std::is_invocable_v); +static_assert(!std::is_invocable_v); constexpr bool testReturnTypes() { { diff --git a/libcxx/test/std/ranges/range.access/end.pass.cpp b/libcxx/test/std/ranges/range.access/end.pass.cpp --- a/libcxx/test/std/ranges/range.access/end.pass.cpp +++ b/libcxx/test/std/ranges/range.access/end.pass.cpp @@ -37,16 +37,19 @@ struct EndMember { int x; - constexpr const int *begin() const { return nullptr; } + const int *begin() const; constexpr const int *end() const { return &x; } }; // Ensure that we can't call with rvalues with borrowing disabled. -static_assert( std::is_invocable_v); -static_assert( std::is_invocable_v); -static_assert(!std::is_invocable_v); +static_assert( std::is_invocable_v); +static_assert(!std::is_invocable_v); +static_assert( std::is_invocable_v); +static_assert(!std::is_invocable_v); static_assert( std::is_invocable_v); +static_assert(!std::is_invocable_v); static_assert( std::is_invocable_v); +static_assert(!std::is_invocable_v); constexpr bool testReturnTypes() { {