diff options
Diffstat (limited to 'contrib/llvm-project/libcxx/include/__ranges/access.h')
-rw-r--r-- | contrib/llvm-project/libcxx/include/__ranges/access.h | 237 |
1 files changed, 110 insertions, 127 deletions
diff --git a/contrib/llvm-project/libcxx/include/__ranges/access.h b/contrib/llvm-project/libcxx/include/__ranges/access.h index 502bd5e951c4..263fdd637fd9 100644 --- a/contrib/llvm-project/libcxx/include/__ranges/access.h +++ b/contrib/llvm-project/libcxx/include/__ranges/access.h @@ -32,138 +32,121 @@ _LIBCPP_BEGIN_NAMESPACE_STD #if _LIBCPP_STD_VER >= 20 namespace ranges { - template <class _Tp> - concept __can_borrow = - is_lvalue_reference_v<_Tp> || enable_borrowed_range<remove_cvref_t<_Tp>>; +template <class _Tp> +concept __can_borrow = is_lvalue_reference_v<_Tp> || enable_borrowed_range<remove_cvref_t<_Tp>>; } // namespace ranges // [range.access.begin] namespace ranges { namespace __begin { - template <class _Tp> - concept __member_begin = - __can_borrow<_Tp> && - __workaround_52970<_Tp> && - requires(_Tp&& __t) { - { _LIBCPP_AUTO_CAST(__t.begin()) } -> input_or_output_iterator; - }; +template <class _Tp> +concept __member_begin = __can_borrow<_Tp> && __workaround_52970<_Tp> && requires(_Tp&& __t) { + { _LIBCPP_AUTO_CAST(__t.begin()) } -> input_or_output_iterator; +}; - void begin(auto&) = delete; - void begin(const auto&) = delete; +void begin(auto&) = delete; +void begin(const auto&) = delete; - template <class _Tp> - concept __unqualified_begin = - !__member_begin<_Tp> && - __can_borrow<_Tp> && - __class_or_enum<remove_cvref_t<_Tp>> && - requires(_Tp && __t) { +template <class _Tp> +concept __unqualified_begin = + !__member_begin<_Tp> && __can_borrow<_Tp> && __class_or_enum<remove_cvref_t<_Tp>> && requires(_Tp&& __t) { { _LIBCPP_AUTO_CAST(begin(__t)) } -> input_or_output_iterator; }; - struct __fn { - template <class _Tp> - [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp (&__t)[]) const noexcept - requires (sizeof(_Tp) >= 0) // Disallow incomplete element types. - { - return __t + 0; - } - - template <class _Tp, size_t _Np> - [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp (&__t)[_Np]) const noexcept - requires (sizeof(_Tp) >= 0) // Disallow incomplete element types. - { - return __t + 0; - } - - template <class _Tp> - requires __member_begin<_Tp> - [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t) const - noexcept(noexcept(_LIBCPP_AUTO_CAST(__t.begin()))) - { - return _LIBCPP_AUTO_CAST(__t.begin()); - } - - template <class _Tp> - requires __unqualified_begin<_Tp> - [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t) const - noexcept(noexcept(_LIBCPP_AUTO_CAST(begin(__t)))) - { - return _LIBCPP_AUTO_CAST(begin(__t)); - } - - void operator()(auto&&) const = delete; - }; +struct __fn { + template <class _Tp> + [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp (&__t)[]) const noexcept + requires(sizeof(_Tp) >= 0) // Disallow incomplete element types. + { + return __t + 0; + } + + template <class _Tp, size_t _Np> + [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp (&__t)[_Np]) const noexcept + requires(sizeof(_Tp) >= 0) // Disallow incomplete element types. + { + return __t + 0; + } + + template <class _Tp> + requires __member_begin<_Tp> + [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t) const + noexcept(noexcept(_LIBCPP_AUTO_CAST(__t.begin()))) { + return _LIBCPP_AUTO_CAST(__t.begin()); + } + + template <class _Tp> + requires __unqualified_begin<_Tp> + [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t) const + noexcept(noexcept(_LIBCPP_AUTO_CAST(begin(__t)))) { + return _LIBCPP_AUTO_CAST(begin(__t)); + } + + void operator()(auto&&) const = delete; +}; } // namespace __begin inline namespace __cpo { - inline constexpr auto begin = __begin::__fn{}; +inline constexpr auto begin = __begin::__fn{}; } // namespace __cpo } // namespace ranges // [range.range] namespace ranges { - template <class _Tp> - using iterator_t = decltype(ranges::begin(std::declval<_Tp&>())); +template <class _Tp> +using iterator_t = decltype(ranges::begin(std::declval<_Tp&>())); } // namespace ranges // [range.access.end] namespace ranges { namespace __end { - template <class _Tp> - concept __member_end = - __can_borrow<_Tp> && - __workaround_52970<_Tp> && - requires(_Tp&& __t) { +template <class _Tp> +concept __member_end = __can_borrow<_Tp> && __workaround_52970<_Tp> && requires(_Tp&& __t) { + typename iterator_t<_Tp>; + { _LIBCPP_AUTO_CAST(__t.end()) } -> sentinel_for<iterator_t<_Tp>>; +}; + +void end(auto&) = delete; +void end(const auto&) = delete; + +template <class _Tp> +concept __unqualified_end = + !__member_end<_Tp> && __can_borrow<_Tp> && __class_or_enum<remove_cvref_t<_Tp>> && requires(_Tp&& __t) { typename iterator_t<_Tp>; - { _LIBCPP_AUTO_CAST(__t.end()) } -> sentinel_for<iterator_t<_Tp>>; + { _LIBCPP_AUTO_CAST(end(__t)) } -> sentinel_for<iterator_t<_Tp>>; }; - void end(auto&) = delete; - void end(const auto&) = delete; +struct __fn { + template <class _Tp, size_t _Np> + [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp (&__t)[_Np]) const noexcept + requires(sizeof(_Tp) >= 0) // Disallow incomplete element types. + { + return __t + _Np; + } template <class _Tp> - concept __unqualified_end = - !__member_end<_Tp> && - __can_borrow<_Tp> && - __class_or_enum<remove_cvref_t<_Tp>> && - requires(_Tp && __t) { - typename iterator_t<_Tp>; - { _LIBCPP_AUTO_CAST(end(__t)) } -> sentinel_for<iterator_t<_Tp>>; - }; + requires __member_end<_Tp> + [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t) const + noexcept(noexcept(_LIBCPP_AUTO_CAST(__t.end()))) { + return _LIBCPP_AUTO_CAST(__t.end()); + } - struct __fn { - template <class _Tp, size_t _Np> - [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp (&__t)[_Np]) const noexcept - requires (sizeof(_Tp) >= 0) // Disallow incomplete element types. - { - return __t + _Np; - } - - template <class _Tp> - requires __member_end<_Tp> - [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t) const - noexcept(noexcept(_LIBCPP_AUTO_CAST(__t.end()))) - { - return _LIBCPP_AUTO_CAST(__t.end()); - } - - template <class _Tp> - requires __unqualified_end<_Tp> - [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t) const - noexcept(noexcept(_LIBCPP_AUTO_CAST(end(__t)))) - { - return _LIBCPP_AUTO_CAST(end(__t)); - } - - void operator()(auto&&) const = delete; - }; + template <class _Tp> + requires __unqualified_end<_Tp> + [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t) const + noexcept(noexcept(_LIBCPP_AUTO_CAST(end(__t)))) { + return _LIBCPP_AUTO_CAST(end(__t)); + } + + void operator()(auto&&) const = delete; +}; } // namespace __end inline namespace __cpo { - inline constexpr auto end = __end::__fn{}; +inline constexpr auto end = __end::__fn{}; } // namespace __cpo } // namespace ranges @@ -171,27 +154,27 @@ inline namespace __cpo { namespace ranges { namespace __cbegin { - struct __fn { - template <class _Tp> - requires is_lvalue_reference_v<_Tp&&> - [[nodiscard]] _LIBCPP_HIDE_FROM_ABI - constexpr auto operator()(_Tp&& __t) const +struct __fn { + template <class _Tp> + requires is_lvalue_reference_v<_Tp&&> + [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t) const noexcept(noexcept(ranges::begin(static_cast<const remove_reference_t<_Tp>&>(__t)))) - -> decltype( ranges::begin(static_cast<const remove_reference_t<_Tp>&>(__t))) - { return ranges::begin(static_cast<const remove_reference_t<_Tp>&>(__t)); } + -> decltype(ranges::begin(static_cast<const remove_reference_t<_Tp>&>(__t))) { + return ranges::begin(static_cast<const remove_reference_t<_Tp>&>(__t)); + } - template <class _Tp> - requires is_rvalue_reference_v<_Tp&&> - [[nodiscard]] _LIBCPP_HIDE_FROM_ABI - constexpr auto operator()(_Tp&& __t) const + template <class _Tp> + requires is_rvalue_reference_v<_Tp&&> + [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t) const noexcept(noexcept(ranges::begin(static_cast<const _Tp&&>(__t)))) - -> decltype( ranges::begin(static_cast<const _Tp&&>(__t))) - { return ranges::begin(static_cast<const _Tp&&>(__t)); } - }; + -> decltype(ranges::begin(static_cast<const _Tp&&>(__t))) { + return ranges::begin(static_cast<const _Tp&&>(__t)); + } +}; } // namespace __cbegin inline namespace __cpo { - inline constexpr auto cbegin = __cbegin::__fn{}; +inline constexpr auto cbegin = __cbegin::__fn{}; } // namespace __cpo } // namespace ranges @@ -199,27 +182,27 @@ inline namespace __cpo { namespace ranges { namespace __cend { - struct __fn { - template <class _Tp> - requires is_lvalue_reference_v<_Tp&&> - [[nodiscard]] _LIBCPP_HIDE_FROM_ABI - constexpr auto operator()(_Tp&& __t) const +struct __fn { + template <class _Tp> + requires is_lvalue_reference_v<_Tp&&> + [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t) const noexcept(noexcept(ranges::end(static_cast<const remove_reference_t<_Tp>&>(__t)))) - -> decltype( ranges::end(static_cast<const remove_reference_t<_Tp>&>(__t))) - { return ranges::end(static_cast<const remove_reference_t<_Tp>&>(__t)); } + -> decltype(ranges::end(static_cast<const remove_reference_t<_Tp>&>(__t))) { + return ranges::end(static_cast<const remove_reference_t<_Tp>&>(__t)); + } - template <class _Tp> - requires is_rvalue_reference_v<_Tp&&> - [[nodiscard]] _LIBCPP_HIDE_FROM_ABI - constexpr auto operator()(_Tp&& __t) const + template <class _Tp> + requires is_rvalue_reference_v<_Tp&&> + [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t) const noexcept(noexcept(ranges::end(static_cast<const _Tp&&>(__t)))) - -> decltype( ranges::end(static_cast<const _Tp&&>(__t))) - { return ranges::end(static_cast<const _Tp&&>(__t)); } - }; + -> decltype(ranges::end(static_cast<const _Tp&&>(__t))) { + return ranges::end(static_cast<const _Tp&&>(__t)); + } +}; } // namespace __cend inline namespace __cpo { - inline constexpr auto cend = __cend::__fn{}; +inline constexpr auto cend = __cend::__fn{}; } // namespace __cpo } // namespace ranges |