diff options
Diffstat (limited to 'libcxx/include/__iterator')
| -rw-r--r-- | libcxx/include/__iterator/concepts.h | 15 | ||||
| -rw-r--r-- | libcxx/include/__iterator/distance.h | 35 | ||||
| -rw-r--r-- | libcxx/include/__iterator/segmented_iterator.h | 5 | ||||
| -rw-r--r-- | libcxx/include/__iterator/wrap_iter.h | 4 |
4 files changed, 23 insertions, 36 deletions
diff --git a/libcxx/include/__iterator/concepts.h b/libcxx/include/__iterator/concepts.h index f386887..3b43920 100644 --- a/libcxx/include/__iterator/concepts.h +++ b/libcxx/include/__iterator/concepts.h @@ -117,15 +117,12 @@ template <class _Tp> concept __signed_integer_like = signed_integral<_Tp>; template <class _Ip> -concept weakly_incrementable = - // TODO: remove this once the clang bug is fixed (https://llvm.org/PR48173). - !same_as<_Ip, bool> && // Currently, clang does not handle bool correctly. - movable<_Ip> && requires(_Ip __i) { - typename iter_difference_t<_Ip>; - requires __signed_integer_like<iter_difference_t<_Ip>>; - { ++__i } -> same_as<_Ip&>; // not required to be equality-preserving - __i++; // not required to be equality-preserving - }; +concept weakly_incrementable = movable<_Ip> && requires(_Ip __i) { + typename iter_difference_t<_Ip>; + requires __signed_integer_like<iter_difference_t<_Ip>>; + { ++__i } -> same_as<_Ip&>; // not required to be equality-preserving + __i++; // not required to be equality-preserving +}; // [iterator.concept.inc] template <class _Ip> diff --git a/libcxx/include/__iterator/distance.h b/libcxx/include/__iterator/distance.h index 9be9db0..1a9fbf2 100644 --- a/libcxx/include/__iterator/distance.h +++ b/libcxx/include/__iterator/distance.h @@ -11,6 +11,7 @@ #define _LIBCPP___ITERATOR_DISTANCE_H #include <__algorithm/for_each_segment.h> +#include <__concepts/same_as.h> #include <__config> #include <__iterator/concepts.h> #include <__iterator/incrementable_traits.h> @@ -41,35 +42,29 @@ template <class _Iter> using __iter_distance_t _LIBCPP_NODEBUG = typename iterator_traits<_Iter>::difference_type; #endif -template <class _InputIter, class _Sent> -inline _LIBCPP_HIDE_FROM_ABI -_LIBCPP_CONSTEXPR_SINCE_CXX17 __iter_distance_t<_InputIter> __distance(_InputIter __first, _Sent __last) { - __iter_distance_t<_InputIter> __r(0); - for (; __first != __last; ++__first) - ++__r; - return __r; -} - template <class _RandIter, __enable_if_t<__has_random_access_iterator_category<_RandIter>::value, int> = 0> inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 __iter_distance_t<_RandIter> __distance(_RandIter __first, _RandIter __last) { return __last - __first; } +template <class _InputIter, class _Sent> +inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 __iter_distance_t<_InputIter> +__distance(_InputIter __first, _Sent __last) { + __iter_distance_t<_InputIter> __r(0); #if _LIBCPP_STD_VER >= 20 -template <class _SegmentedIter, - __enable_if_t<!__has_random_access_iterator_category<_SegmentedIter>::value && - __is_segmented_iterator_v<_SegmentedIter>, - int> = 0> -inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 __iter_distance_t<_SegmentedIter> -__distance(_SegmentedIter __first, _SegmentedIter __last) { - __iter_distance_t<_SegmentedIter> __r(0); - std::__for_each_segment(__first, __last, [&__r](auto __lfirst, auto __llast) { - __r += std::__distance(__lfirst, __llast); - }); + if constexpr (same_as<_InputIter, _Sent> && __is_segmented_iterator_v<_InputIter>) { + std::__for_each_segment(__first, __last, [&__r](auto __lfirst, auto __llast) { + __r += std::__distance(__lfirst, __llast); + }); + } else +#endif + { + for (; __first != __last; ++__first) + ++__r; + } return __r; } -#endif // _LIBCPP_STD_VER >= 20 template <class _InputIter> inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 typename iterator_traits<_InputIter>::difference_type diff --git a/libcxx/include/__iterator/segmented_iterator.h b/libcxx/include/__iterator/segmented_iterator.h index 5df9737..dc56a74 100644 --- a/libcxx/include/__iterator/segmented_iterator.h +++ b/libcxx/include/__iterator/segmented_iterator.h @@ -75,11 +75,6 @@ inline const bool __has_specialization_v<_Tp, sizeof(_Tp) * 0> = true; template <class _Iterator> inline const bool __is_segmented_iterator_v = __has_specialization_v<__segmented_iterator_traits<_Iterator> >; -template <class _SegmentedIterator> -struct __has_random_access_local_iterator - : __has_random_access_iterator_category< - typename __segmented_iterator_traits< _SegmentedIterator >::__local_iterator > {}; - _LIBCPP_END_NAMESPACE_STD #endif // _LIBCPP___SEGMENTED_ITERATOR_H diff --git a/libcxx/include/__iterator/wrap_iter.h b/libcxx/include/__iterator/wrap_iter.h index d18d968..98745f6 100644 --- a/libcxx/include/__iterator/wrap_iter.h +++ b/libcxx/include/__iterator/wrap_iter.h @@ -117,8 +117,8 @@ private: friend class span; template <class _Tp, size_t _Size> friend struct array; - template <class _Tp> - friend class optional; + template <class _Tp, class> + friend struct __optional_iterator; }; template <class _Iter1> |
