Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-03 08:13:40

0001 // -*- C++ -*-
0002 //===----------------------------------------------------------------------===//
0003 //
0004 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0005 // See https://llvm.org/LICENSE.txt for license information.
0006 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0007 //
0008 //===----------------------------------------------------------------------===//
0009 
0010 #ifndef _LIBCPP___CXX03___RANGES_DATA_H
0011 #define _LIBCPP___CXX03___RANGES_DATA_H
0012 
0013 #include <__cxx03/__concepts/class_or_enum.h>
0014 #include <__cxx03/__config>
0015 #include <__cxx03/__iterator/concepts.h>
0016 #include <__cxx03/__iterator/iterator_traits.h>
0017 #include <__cxx03/__memory/pointer_traits.h>
0018 #include <__cxx03/__ranges/access.h>
0019 #include <__cxx03/__type_traits/decay.h>
0020 #include <__cxx03/__type_traits/is_object.h>
0021 #include <__cxx03/__type_traits/is_pointer.h>
0022 #include <__cxx03/__type_traits/is_reference.h>
0023 #include <__cxx03/__type_traits/remove_pointer.h>
0024 #include <__cxx03/__type_traits/remove_reference.h>
0025 #include <__cxx03/__utility/auto_cast.h>
0026 
0027 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
0028 #  pragma GCC system_header
0029 #endif
0030 
0031 _LIBCPP_BEGIN_NAMESPACE_STD
0032 
0033 #if _LIBCPP_STD_VER >= 20
0034 
0035 // [range.prim.data]
0036 
0037 namespace ranges {
0038 namespace __data {
0039 template <class _Tp>
0040 concept __ptr_to_object = is_pointer_v<_Tp> && is_object_v<remove_pointer_t<_Tp>>;
0041 
0042 template <class _Tp>
0043 concept __member_data = __can_borrow<_Tp> && requires(_Tp&& __t) {
0044   { _LIBCPP_AUTO_CAST(__t.data()) } -> __ptr_to_object;
0045 };
0046 
0047 template <class _Tp>
0048 concept __ranges_begin_invocable = !__member_data<_Tp> && __can_borrow<_Tp> && requires(_Tp&& __t) {
0049   { ranges::begin(__t) } -> contiguous_iterator;
0050 };
0051 
0052 struct __fn {
0053   template <__member_data _Tp>
0054   _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t) const noexcept(noexcept(__t.data())) {
0055     return __t.data();
0056   }
0057 
0058   template <__ranges_begin_invocable _Tp>
0059   _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t) const
0060       noexcept(noexcept(std::to_address(ranges::begin(__t)))) {
0061     return std::to_address(ranges::begin(__t));
0062   }
0063 };
0064 } // namespace __data
0065 
0066 inline namespace __cpo {
0067 inline constexpr auto data = __data::__fn{};
0068 } // namespace __cpo
0069 } // namespace ranges
0070 
0071 // [range.prim.cdata]
0072 
0073 namespace ranges {
0074 namespace __cdata {
0075 struct __fn {
0076   template <class _Tp>
0077     requires is_lvalue_reference_v<_Tp&&>
0078   [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t) const
0079       noexcept(noexcept(ranges::data(static_cast<const remove_reference_t<_Tp>&>(__t))))
0080           -> decltype(ranges::data(static_cast<const remove_reference_t<_Tp>&>(__t))) {
0081     return ranges::data(static_cast<const remove_reference_t<_Tp>&>(__t));
0082   }
0083 
0084   template <class _Tp>
0085     requires is_rvalue_reference_v<_Tp&&>
0086   [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t) const noexcept(
0087       noexcept(ranges::data(static_cast<const _Tp&&>(__t)))) -> decltype(ranges::data(static_cast<const _Tp&&>(__t))) {
0088     return ranges::data(static_cast<const _Tp&&>(__t));
0089   }
0090 };
0091 } // namespace __cdata
0092 
0093 inline namespace __cpo {
0094 inline constexpr auto cdata = __cdata::__fn{};
0095 } // namespace __cpo
0096 } // namespace ranges
0097 
0098 #endif // _LIBCPP_STD_VER >= 20
0099 
0100 _LIBCPP_END_NAMESPACE_STD
0101 
0102 #endif // _LIBCPP___CXX03___RANGES_DATA_H