File indexing completed on 2026-05-03 08:13:12
0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef _LIBCPP___ALGORITHM_SWAP_RANGES_H
0010 #define _LIBCPP___ALGORITHM_SWAP_RANGES_H
0011
0012 #include <__algorithm/iterator_operations.h>
0013 #include <__config>
0014 #include <__utility/move.h>
0015 #include <__utility/pair.h>
0016
0017 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
0018 # pragma GCC system_header
0019 #endif
0020
0021 _LIBCPP_PUSH_MACROS
0022 #include <__undef_macros>
0023
0024 _LIBCPP_BEGIN_NAMESPACE_STD
0025
0026
0027 template <class _AlgPolicy, class _ForwardIterator1, class _Sentinel1, class _ForwardIterator2, class _Sentinel2>
0028 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_ForwardIterator1, _ForwardIterator2>
0029 __swap_ranges(_ForwardIterator1 __first1, _Sentinel1 __last1, _ForwardIterator2 __first2, _Sentinel2 __last2) {
0030 while (__first1 != __last1 && __first2 != __last2) {
0031 _IterOps<_AlgPolicy>::iter_swap(__first1, __first2);
0032 ++__first1;
0033 ++__first2;
0034 }
0035
0036 return pair<_ForwardIterator1, _ForwardIterator2>(std::move(__first1), std::move(__first2));
0037 }
0038
0039
0040 template <class _AlgPolicy, class _ForwardIterator1, class _Sentinel1, class _ForwardIterator2>
0041 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_ForwardIterator1, _ForwardIterator2>
0042 __swap_ranges(_ForwardIterator1 __first1, _Sentinel1 __last1, _ForwardIterator2 __first2) {
0043 while (__first1 != __last1) {
0044 _IterOps<_AlgPolicy>::iter_swap(__first1, __first2);
0045 ++__first1;
0046 ++__first2;
0047 }
0048
0049 return pair<_ForwardIterator1, _ForwardIterator2>(std::move(__first1), std::move(__first2));
0050 }
0051
0052 template <class _ForwardIterator1, class _ForwardIterator2>
0053 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator2
0054 swap_ranges(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2) {
0055 return std::__swap_ranges<_ClassicAlgPolicy>(std::move(__first1), std::move(__last1), std::move(__first2)).second;
0056 }
0057
0058 _LIBCPP_END_NAMESPACE_STD
0059
0060 _LIBCPP_POP_MACROS
0061
0062 #endif