diff options
author | Arthur O'Dwyer <arthur.j.odwyer@gmail.com> | 2021-05-19 11:54:31 -0400 |
---|---|---|
committer | Arthur O'Dwyer <arthur.j.odwyer@gmail.com> | 2021-05-24 17:30:21 -0400 |
commit | fc9248877d07132981f2d598d3684de81d12d0b8 (patch) | |
tree | 422eec0edf4a1c8415aa32cf6e76c1cf459c4b3d /libcxx/include/__iterator | |
parent | 13dd65b3a1a3ac049b5f3a9712059f7c61649bea (diff) | |
download | llvm-fc9248877d07132981f2d598d3684de81d12d0b8.tar.gz |
[libc++] Assume that __wrap_iter always wraps a fancy pointer.
Not only do we conscientiously avoid using `__wrap_iter` for non-contiguous
iterators (in vector, string, span...) but also we make the assumption
(in regex) that `__wrap_iter<_Iter>` is contiguous for all `_Iter`.
So `__wrap_iter<reverse_iterator<int*>>` should be considered IFNDR,
and every `__wrap_iter` should correctly advertise contiguity in C++20.
Drive-by simplify some type traits.
Reviewed as part of https://reviews.llvm.org/D102781
Diffstat (limited to 'libcxx/include/__iterator')
-rw-r--r-- | libcxx/include/__iterator/iterator_traits.h | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/libcxx/include/__iterator/iterator_traits.h b/libcxx/include/__iterator/iterator_traits.h index ebffc974f0e1..307ee143c1d2 100644 --- a/libcxx/include/__iterator/iterator_traits.h +++ b/libcxx/include/__iterator/iterator_traits.h @@ -428,7 +428,7 @@ struct _LIBCPP_TEMPLATE_VIS iterator_traits<_Tp*> template <class _Tp, class _Up, bool = __has_iterator_category<iterator_traits<_Tp> >::value> struct __has_iterator_category_convertible_to - : _BoolConstant<is_convertible<typename iterator_traits<_Tp>::iterator_category, _Up>::value> + : is_convertible<typename iterator_traits<_Tp>::iterator_category, _Up> {}; template <class _Tp, class _Up> @@ -436,7 +436,7 @@ struct __has_iterator_category_convertible_to<_Tp, _Up, false> : false_type {}; template <class _Tp, class _Up, bool = __has_iterator_concept<_Tp>::value> struct __has_iterator_concept_convertible_to - : _BoolConstant<is_convertible<typename _Tp::iterator_concept, _Up>::value> + : is_convertible<typename _Tp::iterator_concept, _Up> {}; template <class _Tp, class _Up> @@ -454,10 +454,12 @@ struct __is_cpp17_bidirectional_iterator : public __has_iterator_category_conver template <class _Tp> struct __is_cpp17_random_access_iterator : public __has_iterator_category_convertible_to<_Tp, random_access_iterator_tag> {}; -// __is_cpp17_contiguous_iterator determines if an iterator is contiguous, -// either because it advertises itself as such (in C++20) or because it -// is a pointer type or a known trivial wrapper around a pointer type, -// such as __wrap_iter<T*>. +// __is_cpp17_contiguous_iterator determines if an iterator is known by +// libc++ to be contiguous, either because it advertises itself as such +// (in C++20) or because it is a pointer type or a known trivial wrapper +// around a (possibly fancy) pointer type, such as __wrap_iter<T*>. +// Such iterators receive special "contiguous" optimizations in +// std::copy and std::sort. // #if _LIBCPP_STD_VER > 17 template <class _Tp> |