[libcxx-commits] [libcxx] 0ab54c2 - [libc++] Further small cleanups of move_iterator.h. NFC.
Arthur O'Dwyer via libcxx-commits
libcxx-commits at lists.llvm.org
Fri Jan 14 12:43:33 PST 2022
Author: Arthur O'Dwyer
Date: 2022-01-14T15:41:45-05:00
New Revision: 0ab54c28f8b5b2436561f496636b184786b79389
URL: https://github.com/llvm/llvm-project/commit/0ab54c28f8b5b2436561f496636b184786b79389
DIFF: https://github.com/llvm/llvm-project/commit/0ab54c28f8b5b2436561f496636b184786b79389.diff
LOG: [libc++] Further small cleanups of move_iterator.h. NFC.
Differential Revision: https://reviews.llvm.org/D117324
Added:
Modified:
libcxx/include/__iterator/move_iterator.h
Removed:
################################################################################
diff --git a/libcxx/include/__iterator/move_iterator.h b/libcxx/include/__iterator/move_iterator.h
index 5f663621f276..306ce240baf3 100644
--- a/libcxx/include/__iterator/move_iterator.h
+++ b/libcxx/include/__iterator/move_iterator.h
@@ -24,16 +24,19 @@ template <class _Iter>
class _LIBCPP_TEMPLATE_VIS move_iterator
{
public:
- typedef _Iter iterator_type;
+#if _LIBCPP_STD_VER > 17
+ typedef input_iterator_tag iterator_concept;
+#endif
+
+ typedef _Iter iterator_type;
+ typedef _If<
+ __is_cpp17_random_access_iterator<_Iter>::value,
+ random_access_iterator_tag,
+ typename iterator_traits<_Iter>::iterator_category
+ > iterator_category;
typedef typename iterator_traits<iterator_type>::value_type value_type;
typedef typename iterator_traits<iterator_type>::
diff erence_type
diff erence_type;
typedef iterator_type pointer;
- typedef _If<__is_cpp17_random_access_iterator<_Iter>::value,
- random_access_iterator_tag,
- typename iterator_traits<_Iter>::iterator_category> iterator_category;
-#if _LIBCPP_STD_VER > 17
- typedef input_iterator_tag iterator_concept;
-#endif
#ifndef _LIBCPP_CXX03_LANG
typedef typename iterator_traits<iterator_type>::reference __reference;
@@ -50,18 +53,18 @@ class _LIBCPP_TEMPLATE_VIS move_iterator
move_iterator() : __current_() {}
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14
- explicit move_iterator(_Iter __x) : __current_(__x) {}
+ explicit move_iterator(_Iter __i) : __current_(__i) {}
template <class _Up, class = __enable_if_t<
- !is_same<_Up, _Iter>::value && is_convertible<_Up const&, _Iter>::value
+ !is_same<_Up, _Iter>::value && is_convertible<const _Up&, _Iter>::value
> >
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14
move_iterator(const move_iterator<_Up>& __u) : __current_(__u.base()) {}
template <class _Up, class = __enable_if_t<
!is_same<_Up, _Iter>::value &&
- is_convertible<_Up const&, _Iter>::value &&
- is_assignable<_Iter&, _Up const&>::value
+ is_convertible<const _Up&, _Iter>::value &&
+ is_assignable<_Iter&, const _Up&>::value
> >
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14
move_iterator& operator=(const move_iterator<_Up>& __u) {
@@ -71,28 +74,30 @@ class _LIBCPP_TEMPLATE_VIS move_iterator
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14
_Iter base() const { return __current_; }
+
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14
reference operator*() const { return static_cast<reference>(*__current_); }
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14
- pointer operator->() const { return __current_; }
+ pointer operator->() const { return __current_; }
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14
+ reference operator[](
diff erence_type __n) const { return static_cast<reference>(__current_[__n]); }
+
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14
move_iterator& operator++() { ++__current_; return *this; }
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14
- move_iterator operator++(int) { move_iterator __tmp(*this); ++__current_; return __tmp; }
+ move_iterator operator++(int) { move_iterator __tmp(*this); ++__current_; return __tmp; }
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14
move_iterator& operator--() { --__current_; return *this; }
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14
- move_iterator operator--(int) { move_iterator __tmp(*this); --__current_; return __tmp; }
+ move_iterator operator--(int) { move_iterator __tmp(*this); --__current_; return __tmp; }
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14
- move_iterator operator+ (
diff erence_type __n) const { return move_iterator(__current_ + __n); }
+ move_iterator operator+(
diff erence_type __n) const { return move_iterator(__current_ + __n); }
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14
move_iterator& operator+=(
diff erence_type __n) { __current_ += __n; return *this; }
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14
- move_iterator operator- (
diff erence_type __n) const { return move_iterator(__current_ - __n); }
+ move_iterator operator-(
diff erence_type __n) const { return move_iterator(__current_ - __n); }
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14
move_iterator& operator-=(
diff erence_type __n) { __current_ -= __n; return *this; }
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14
- reference operator[](
diff erence_type __n) const { return static_cast<reference>(__current_[__n]); }
private:
_Iter __current_;
@@ -100,58 +105,51 @@ class _LIBCPP_TEMPLATE_VIS move_iterator
template <class _Iter1, class _Iter2>
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14
-bool
-operator==(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y)
+bool operator==(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y)
{
return __x.base() == __y.base();
}
template <class _Iter1, class _Iter2>
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14
-bool
-operator<(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y)
+bool operator!=(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y)
{
- return __x.base() < __y.base();
+ return __x.base() != __y.base();
}
template <class _Iter1, class _Iter2>
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14
-bool
-operator!=(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y)
+bool operator<(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y)
{
- return __x.base() != __y.base();
+ return __x.base() < __y.base();
}
template <class _Iter1, class _Iter2>
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14
-bool
-operator>(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y)
+bool operator>(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y)
{
return __x.base() > __y.base();
}
template <class _Iter1, class _Iter2>
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14
-bool
-operator>=(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y)
+bool operator<=(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y)
{
- return __x.base() >= __y.base();
+ return __x.base() <= __y.base();
}
template <class _Iter1, class _Iter2>
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14
-bool
-operator<=(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y)
+bool operator>=(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y)
{
- return __x.base() <= __y.base();
+ return __x.base() >= __y.base();
}
#ifndef _LIBCPP_CXX03_LANG
template <class _Iter1, class _Iter2>
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14
-auto
-operator-(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y)
--> decltype(__x.base() - __y.base())
+auto operator-(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y)
+ -> decltype(__x.base() - __y.base())
{
return __x.base() - __y.base();
}
More information about the libcxx-commits
mailing list