diff --git a/libcxx/include/__ranges/view_interface.h b/libcxx/include/__ranges/view_interface.h --- a/libcxx/include/__ranges/view_interface.h +++ b/libcxx/include/__ranges/view_interface.h @@ -9,6 +9,8 @@ #ifndef _LIBCPP___RANGES_VIEW_INTERFACE_H #define _LIBCPP___RANGES_VIEW_INTERFACE_H +#include <__concepts/derived_from.h> +#include <__concepts/same_as.h> #include <__config> #include <__debug> #include <__iterator/concepts.h> @@ -18,7 +20,6 @@ #include <__ranges/access.h> #include <__ranges/concepts.h> #include <__ranges/empty.h> -#include #include #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) @@ -31,12 +32,6 @@ namespace ranges { -template -concept __can_empty = requires(_Tp __t) { ranges::empty(__t); }; - -template -void __implicitly_convert_to(type_identity_t<_Tp>) noexcept; - template requires is_class_v<_Derived> && same_as<_Derived, remove_cv_t<_Derived>> class view_interface { @@ -55,7 +50,6 @@ public: template [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool empty() - noexcept(noexcept(__implicitly_convert_to(ranges::begin(__derived()) == ranges::end(__derived())))) requires forward_range<_D2> { return ranges::begin(__derived()) == ranges::end(__derived()); @@ -63,7 +57,6 @@ template [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool empty() const - noexcept(noexcept(__implicitly_convert_to(ranges::begin(__derived()) == ranges::end(__derived())))) requires forward_range { return ranges::begin(__derived()) == ranges::end(__derived()); @@ -72,8 +65,7 @@ template _LIBCPP_HIDE_FROM_ABI constexpr explicit operator bool() - noexcept(noexcept(ranges::empty(declval<_D2>()))) - requires __can_empty<_D2> + requires requires (_D2& __t) { ranges::empty(__t); } { return !ranges::empty(__derived()); } @@ -81,8 +73,7 @@ template _LIBCPP_HIDE_FROM_ABI constexpr explicit operator bool() const - noexcept(noexcept(ranges::empty(declval()))) - requires __can_empty + requires requires (const _D2& __t) { ranges::empty(__t); } { return !ranges::empty(__derived()); } @@ -90,7 +81,6 @@ template _LIBCPP_HIDE_FROM_ABI constexpr auto data() - noexcept(noexcept(std::to_address(ranges::begin(__derived())))) requires contiguous_iterator> { return std::to_address(ranges::begin(__derived())); @@ -99,7 +89,6 @@ template _LIBCPP_HIDE_FROM_ABI constexpr auto data() const - noexcept(noexcept(std::to_address(ranges::begin(__derived())))) requires range && contiguous_iterator> { return std::to_address(ranges::begin(__derived())); @@ -108,9 +97,7 @@ template _LIBCPP_HIDE_FROM_ABI constexpr auto size() - noexcept(noexcept(ranges::end(__derived()) - ranges::begin(__derived()))) - requires forward_range<_D2> - && sized_sentinel_for, iterator_t<_D2>> + requires forward_range<_D2> && sized_sentinel_for, iterator_t<_D2>> { return ranges::end(__derived()) - ranges::begin(__derived()); } @@ -118,9 +105,7 @@ template _LIBCPP_HIDE_FROM_ABI constexpr auto size() const - noexcept(noexcept(ranges::end(__derived()) - ranges::begin(__derived()))) - requires forward_range - && sized_sentinel_for, iterator_t> + requires forward_range && sized_sentinel_for, iterator_t> { return ranges::end(__derived()) - ranges::begin(__derived()); } @@ -128,7 +113,6 @@ template _LIBCPP_HIDE_FROM_ABI constexpr decltype(auto) front() - noexcept(noexcept(*ranges::begin(__derived()))) requires forward_range<_D2> { _LIBCPP_ASSERT(!empty(), @@ -139,7 +123,6 @@ template _LIBCPP_HIDE_FROM_ABI constexpr decltype(auto) front() const - noexcept(noexcept(*ranges::begin(__derived()))) requires forward_range { _LIBCPP_ASSERT(!empty(), @@ -150,7 +133,6 @@ template _LIBCPP_HIDE_FROM_ABI constexpr decltype(auto) back() - noexcept(noexcept(*ranges::prev(ranges::end(__derived())))) requires bidirectional_range<_D2> && common_range<_D2> { _LIBCPP_ASSERT(!empty(), @@ -161,7 +143,6 @@ template _LIBCPP_HIDE_FROM_ABI constexpr decltype(auto) back() const - noexcept(noexcept(*ranges::prev(ranges::end(__derived())))) requires bidirectional_range && common_range { _LIBCPP_ASSERT(!empty(), @@ -172,7 +153,6 @@ template _LIBCPP_HIDE_FROM_ABI constexpr decltype(auto) operator[](range_difference_t<_RARange> __index) - noexcept(noexcept(ranges::begin(__derived())[__index])) { return ranges::begin(__derived())[__index]; } @@ -180,7 +160,6 @@ template _LIBCPP_HIDE_FROM_ABI constexpr decltype(auto) operator[](range_difference_t<_RARange> __index) const - noexcept(noexcept(ranges::begin(__derived())[__index])) { return ranges::begin(__derived())[__index]; } diff --git a/libcxx/test/std/ranges/range.utility/view.interface/view.interface.pass.cpp b/libcxx/test/std/ranges/range.utility/view.interface/view.interface.pass.cpp --- a/libcxx/test/std/ranges/range.utility/view.interface/view.interface.pass.cpp +++ b/libcxx/test/std/ranges/range.utility/view.interface/view.interface.pass.cpp @@ -126,17 +126,16 @@ }; static_assert(std::ranges::view); -template -struct BoolConvertibleComparison : std::ranges::view_interface> { +struct BoolConvertibleComparison : std::ranges::view_interface { struct ResultType { bool value; - constexpr operator bool() const noexcept(IsNoexcept) { return value; } + constexpr operator bool() const { return value; } }; struct SentinelType { int *base_; - SentinelType() = default; - explicit constexpr SentinelType(int *base) : base_(base) {} + explicit SentinelType() = default; + constexpr explicit SentinelType(int *base) : base_(base) {} friend constexpr ResultType operator==(ForwardIter const& iter, SentinelType const& sent) noexcept { return {iter.base() == sent.base_}; } friend constexpr ResultType operator==(SentinelType const& sent, ForwardIter const& iter) noexcept { return {iter.base() == sent.base_}; } friend constexpr ResultType operator!=(ForwardIter const& iter, SentinelType const& sent) noexcept { return {iter.base() != sent.base_}; } @@ -144,11 +143,10 @@ }; int buff[8] = {0, 1, 2, 3, 4, 5, 6, 7}; - constexpr ForwardIter begin() const noexcept { return ForwardIter(const_cast(buff)); } - constexpr SentinelType end() const noexcept { return SentinelType(const_cast(buff) + 8); } + constexpr ForwardIter begin() const { return ForwardIter(const_cast(buff)); } + constexpr SentinelType end() const { return SentinelType(const_cast(buff) + 8); } }; -static_assert(std::ranges::view>); -static_assert(std::ranges::view>); +static_assert(std::ranges::view); template concept EmptyInvocable = requires (T const& obj) { obj.empty(); }; @@ -189,19 +187,17 @@ MoveOnlyForwardRange moveOnly; assert(!std::move(moveOnly).empty()); - BoolConvertibleComparison boolConv; - BoolConvertibleComparison boolConv2; - LIBCPP_ASSERT_NOEXCEPT(boolConv.empty()); - ASSERT_NOT_NOEXCEPT(boolConv2.empty()); + BoolConvertibleComparison boolConv; + ASSERT_NOT_NOEXCEPT(boolConv.empty()); assert(!boolConv.empty()); - assert(!static_cast const&>(boolConv).empty()); + assert(!static_cast(boolConv).empty()); assert(boolConv); - assert(static_cast const&>(boolConv)); + assert(static_cast(boolConv)); assert(!std::ranges::empty(boolConv)); - assert(!std::ranges::empty(static_cast const&>(boolConv))); + assert(!std::ranges::empty(static_cast(boolConv))); return true; }