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-exception 6 // 7 //===----------------------------------------------------------------------===// 8 9 #ifndef _LIBCPP___ALGORIHTM_ITERATOR_OPERATIONS_H 10 #define _LIBCPP___ALGORIHTM_ITERATOR_OPERATIONS_H 11 12 #include <__config> 13 #include <__iterator/advance.h> 14 #include <__iterator/distance.h> 15 #include <__iterator/iterator_traits.h> 16 17 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 18 # pragma GCC system_header 19 #endif 20 21 _LIBCPP_BEGIN_NAMESPACE_STD 22 23 #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) 24 struct _RangesIterOps { 25 static constexpr auto advance = ranges::advance; 26 static constexpr auto distance = ranges::distance; 27 }; 28 #endif 29 30 struct _StdIterOps { 31 32 template <class _Iterator, class _Distance> 33 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR_AFTER_CXX11 void advance(_Iterator& __iter, _Distance __count) { 34 return std::advance(__iter, __count); 35 } 36 37 template <class _Iterator> 38 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR_AFTER_CXX11 39 typename iterator_traits<_Iterator>::difference_type distance(_Iterator __first, _Iterator __last) { 40 return std::distance(__first, __last); 41 } 42 43 }; 44 45 _LIBCPP_END_NAMESPACE_STD 46 47 #endif // _LIBCPP___ALGORIHTM_ITERATOR_OPERATIONS_H 48