Path: blob/main/contrib/llvm-project/libcxx/include/__iterator/iter_move.h
35233 views
// -*- C++ -*-1//===----------------------------------------------------------------------===//2//3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.4// See https://llvm.org/LICENSE.txt for license information.5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6//7//===----------------------------------------------------------------------===//89#ifndef _LIBCPP___ITERATOR_ITER_MOVE_H10#define _LIBCPP___ITERATOR_ITER_MOVE_H1112#include <__concepts/class_or_enum.h>13#include <__config>14#include <__iterator/iterator_traits.h>15#include <__type_traits/is_reference.h>16#include <__type_traits/remove_cvref.h>17#include <__utility/declval.h>18#include <__utility/forward.h>19#include <__utility/move.h>2021#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)22# pragma GCC system_header23#endif2425_LIBCPP_PUSH_MACROS26#include <__undef_macros>2728_LIBCPP_BEGIN_NAMESPACE_STD2930#if _LIBCPP_STD_VER >= 203132// [iterator.cust.move]3334namespace ranges {35namespace __iter_move {3637void iter_move() = delete;3839template <class _Tp>40concept __unqualified_iter_move = __class_or_enum<remove_cvref_t<_Tp>> && requires(_Tp&& __t) {41// NOLINTNEXTLINE(libcpp-robust-against-adl) iter_swap ADL calls should only be made through ranges::iter_swap42iter_move(std::forward<_Tp>(__t));43};4445template <class _Tp>46concept __move_deref = !__unqualified_iter_move<_Tp> && requires(_Tp&& __t) {47*__t;48requires is_lvalue_reference_v<decltype(*__t)>;49};5051template <class _Tp>52concept __just_deref = !__unqualified_iter_move<_Tp> && !__move_deref<_Tp> && requires(_Tp&& __t) {53*__t;54requires(!is_lvalue_reference_v<decltype(*__t)>);55};5657// [iterator.cust.move]5859struct __fn {60// NOLINTBEGIN(libcpp-robust-against-adl) iter_move ADL calls should only be made through ranges::iter_move61template <class _Ip>62requires __unqualified_iter_move<_Ip>63[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr decltype(auto) operator()(_Ip&& __i) const64noexcept(noexcept(iter_move(std::forward<_Ip>(__i)))) {65return iter_move(std::forward<_Ip>(__i));66}67// NOLINTEND(libcpp-robust-against-adl)6869template <class _Ip>70requires __move_deref<_Ip>71[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Ip&& __i) const72noexcept(noexcept(std::move(*std::forward<_Ip>(__i)))) -> decltype(std::move(*std::forward<_Ip>(__i))) {73return std::move(*std::forward<_Ip>(__i));74}7576template <class _Ip>77requires __just_deref<_Ip>78[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Ip&& __i) const79noexcept(noexcept(*std::forward<_Ip>(__i))) -> decltype(*std::forward<_Ip>(__i)) {80return *std::forward<_Ip>(__i);81}82};83} // namespace __iter_move8485inline namespace __cpo {86inline constexpr auto iter_move = __iter_move::__fn{};87} // namespace __cpo88} // namespace ranges8990template <__dereferenceable _Tp>91requires requires(_Tp& __t) {92{ ranges::iter_move(__t) } -> __can_reference;93}94using iter_rvalue_reference_t = decltype(ranges::iter_move(std::declval<_Tp&>()));9596#endif // _LIBCPP_STD_VER >= 209798_LIBCPP_END_NAMESPACE_STD99100_LIBCPP_POP_MACROS101102#endif // _LIBCPP___ITERATOR_ITER_MOVE_H103104105