Back to home page

EIC code displayed by LXR

 
 

    


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

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___ITERATOR_ITER_MOVE_H
0011 #define _LIBCPP___CXX03___ITERATOR_ITER_MOVE_H
0012 
0013 #include <__cxx03/__concepts/class_or_enum.h>
0014 #include <__cxx03/__config>
0015 #include <__cxx03/__iterator/iterator_traits.h>
0016 #include <__cxx03/__type_traits/is_reference.h>
0017 #include <__cxx03/__type_traits/remove_cvref.h>
0018 #include <__cxx03/__utility/declval.h>
0019 #include <__cxx03/__utility/forward.h>
0020 #include <__cxx03/__utility/move.h>
0021 
0022 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
0023 #  pragma GCC system_header
0024 #endif
0025 
0026 _LIBCPP_PUSH_MACROS
0027 #include <__cxx03/__undef_macros>
0028 
0029 _LIBCPP_BEGIN_NAMESPACE_STD
0030 
0031 #if _LIBCPP_STD_VER >= 20
0032 
0033 // [iterator.cust.move]
0034 
0035 namespace ranges {
0036 namespace __iter_move {
0037 
0038 void iter_move() = delete;
0039 
0040 template <class _Tp>
0041 concept __unqualified_iter_move = __class_or_enum<remove_cvref_t<_Tp>> && requires(_Tp&& __t) {
0042   // NOLINTNEXTLINE(libcpp-robust-against-adl) iter_swap ADL calls should only be made through ranges::iter_swap
0043   iter_move(std::forward<_Tp>(__t));
0044 };
0045 
0046 template <class _Tp>
0047 concept __move_deref = !__unqualified_iter_move<_Tp> && requires(_Tp&& __t) {
0048   *__t;
0049   requires is_lvalue_reference_v<decltype(*__t)>;
0050 };
0051 
0052 template <class _Tp>
0053 concept __just_deref = !__unqualified_iter_move<_Tp> && !__move_deref<_Tp> && requires(_Tp&& __t) {
0054   *__t;
0055   requires(!is_lvalue_reference_v<decltype(*__t)>);
0056 };
0057 
0058 // [iterator.cust.move]
0059 
0060 struct __fn {
0061   // NOLINTBEGIN(libcpp-robust-against-adl) iter_move ADL calls should only be made through ranges::iter_move
0062   template <class _Ip>
0063     requires __unqualified_iter_move<_Ip>
0064   [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr decltype(auto) operator()(_Ip&& __i) const
0065       noexcept(noexcept(iter_move(std::forward<_Ip>(__i)))) {
0066     return iter_move(std::forward<_Ip>(__i));
0067   }
0068   // NOLINTEND(libcpp-robust-against-adl)
0069 
0070   template <class _Ip>
0071     requires __move_deref<_Ip>
0072   [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Ip&& __i) const
0073       noexcept(noexcept(std::move(*std::forward<_Ip>(__i)))) -> decltype(std::move(*std::forward<_Ip>(__i))) {
0074     return std::move(*std::forward<_Ip>(__i));
0075   }
0076 
0077   template <class _Ip>
0078     requires __just_deref<_Ip>
0079   [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Ip&& __i) const
0080       noexcept(noexcept(*std::forward<_Ip>(__i))) -> decltype(*std::forward<_Ip>(__i)) {
0081     return *std::forward<_Ip>(__i);
0082   }
0083 };
0084 } // namespace __iter_move
0085 
0086 inline namespace __cpo {
0087 inline constexpr auto iter_move = __iter_move::__fn{};
0088 } // namespace __cpo
0089 } // namespace ranges
0090 
0091 template <__dereferenceable _Tp>
0092   requires requires(_Tp& __t) {
0093     { ranges::iter_move(__t) } -> __can_reference;
0094   }
0095 using iter_rvalue_reference_t = decltype(ranges::iter_move(std::declval<_Tp&>()));
0096 
0097 #endif // _LIBCPP_STD_VER >= 20
0098 
0099 _LIBCPP_END_NAMESPACE_STD
0100 
0101 _LIBCPP_POP_MACROS
0102 
0103 #endif // _LIBCPP___CXX03___ITERATOR_ITER_MOVE_H