diff options
author | Alon Zakai <alonzakai@gmail.com> | 2013-11-08 15:56:02 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2013-11-08 15:56:02 -0800 |
commit | e0268fa1035a718341c53921eee9318d4a8033cd (patch) | |
tree | 2b3eeb07928f9521498332002444dbfa44f34dfb /system/include/libcxx/iterator | |
parent | a11272805c16be75f5e6d00c8214afcac7ba9d05 (diff) | |
parent | ad1da1e6685d4483e096d7e0bbd8e38e686bd322 (diff) |
Merge pull request #1767 from waywardmonkeys/update-libcxx1.7.2
Update libcxx
Diffstat (limited to 'system/include/libcxx/iterator')
-rw-r--r-- | system/include/libcxx/iterator | 525 |
1 files changed, 108 insertions, 417 deletions
diff --git a/system/include/libcxx/iterator b/system/include/libcxx/iterator index 858510d1..d16aa2aa 100644 --- a/system/include/libcxx/iterator +++ b/system/include/libcxx/iterator @@ -309,6 +309,19 @@ template <class C> auto end(const C& c) -> decltype(c.end()); template <class T, size_t N> T* begin(T (&array)[N]); template <class T, size_t N> T* end(T (&array)[N]); +template <class C> auto cbegin(const C& c) -> decltype(std::begin(c)); // C++14 +template <class C> auto cend(const C& c) -> decltype(std::end(c)); // C++14 +template <class C> auto rbegin(C& c) -> decltype(c.rbegin()); // C++14 +template <class C> auto rbegin(const C& c) -> decltype(c.rbegin()); // C++14 +template <class C> auto rend(C& c) -> decltype(c.rend()); // C++14 +template <class C> auto rend(const C& c) -> decltype(c.rend()); // C++14 +template <class E> reverse_iterator<const E*> rbegin(initializer_list<E> il); // C++14 +template <class E> reverse_iterator<const E*> rend(initializer_list<E> il); // C++14 +template <class T, size_t N> reverse_iterator<T*> rbegin(T (&array)[N]); // C++14 +template <class T, size_t N> reverse_iterator<T*> rend(T (&array)[N]); // C++14 +template <class C> auto crbegin(const C& c) -> decltype(std::rbegin(c)); // C++14 +template <class C> auto crend(const C& c) -> decltype(std::rend(c)); // C++14 + } // std */ @@ -317,11 +330,12 @@ template <class T, size_t N> T* end(T (&array)[N]); #include <type_traits> #include <cstddef> #include <iosfwd> +#include <initializer_list> #ifdef __APPLE__ #include <Availability.h> #endif -#ifdef _LIBCPP_DEBUG2 +#ifdef _LIBCPP_DEBUG # include <__debug> #else # define _LIBCPP_ASSERT(x, m) ((void)0) @@ -333,11 +347,11 @@ template <class T, size_t N> T* end(T (&array)[N]); _LIBCPP_BEGIN_NAMESPACE_STD -struct _LIBCPP_TYPE_VIS input_iterator_tag {}; -struct _LIBCPP_TYPE_VIS output_iterator_tag {}; -struct _LIBCPP_TYPE_VIS forward_iterator_tag : public input_iterator_tag {}; -struct _LIBCPP_TYPE_VIS bidirectional_iterator_tag : public forward_iterator_tag {}; -struct _LIBCPP_TYPE_VIS random_access_iterator_tag : public bidirectional_iterator_tag {}; +struct _LIBCPP_TYPE_VIS_ONLY input_iterator_tag {}; +struct _LIBCPP_TYPE_VIS_ONLY output_iterator_tag {}; +struct _LIBCPP_TYPE_VIS_ONLY forward_iterator_tag : public input_iterator_tag {}; +struct _LIBCPP_TYPE_VIS_ONLY bidirectional_iterator_tag : public forward_iterator_tag {}; +struct _LIBCPP_TYPE_VIS_ONLY random_access_iterator_tag : public bidirectional_iterator_tag {}; template <class _Tp> struct __has_iterator_category @@ -380,11 +394,11 @@ struct __iterator_traits<_Iter, true> // the client expects instead of failing at compile time. template <class _Iter> -struct _LIBCPP_TYPE_VIS iterator_traits +struct _LIBCPP_TYPE_VIS_ONLY iterator_traits : __iterator_traits<_Iter, __has_iterator_category<_Iter>::value> {}; template<class _Tp> -struct _LIBCPP_TYPE_VIS iterator_traits<_Tp*> +struct _LIBCPP_TYPE_VIS_ONLY iterator_traits<_Tp*> { typedef ptrdiff_t difference_type; typedef typename remove_const<_Tp>::type value_type; @@ -415,7 +429,7 @@ struct __is_random_access_iterator : public __has_iterator_category_convertible_ template<class _Category, class _Tp, class _Distance = ptrdiff_t, class _Pointer = _Tp*, class _Reference = _Tp&> -struct _LIBCPP_TYPE_VIS iterator +struct _LIBCPP_TYPE_VIS_ONLY iterator { typedef _Tp value_type; typedef _Distance difference_type; @@ -512,7 +526,7 @@ prev(_BidiretionalIter __x, } template <class _Iter> -class _LIBCPP_TYPE_VIS reverse_iterator +class _LIBCPP_TYPE_VIS_ONLY reverse_iterator : public iterator<typename iterator_traits<_Iter>::iterator_category, typename iterator_traits<_Iter>::value_type, typename iterator_traits<_Iter>::difference_type, @@ -619,7 +633,7 @@ operator+(typename reverse_iterator<_Iter>::difference_type __n, const reverse_i } template <class _Container> -class _LIBCPP_TYPE_VIS back_insert_iterator +class _LIBCPP_TYPE_VIS_ONLY back_insert_iterator : public iterator<output_iterator_tag, void, void, @@ -652,7 +666,7 @@ back_inserter(_Container& __x) } template <class _Container> -class _LIBCPP_TYPE_VIS front_insert_iterator +class _LIBCPP_TYPE_VIS_ONLY front_insert_iterator : public iterator<output_iterator_tag, void, void, @@ -685,7 +699,7 @@ front_inserter(_Container& __x) } template <class _Container> -class _LIBCPP_TYPE_VIS insert_iterator +class _LIBCPP_TYPE_VIS_ONLY insert_iterator : public iterator<output_iterator_tag, void, void, @@ -721,7 +735,7 @@ inserter(_Container& __x, typename _Container::iterator __i) template <class _Tp, class _CharT = char, class _Traits = char_traits<_CharT>, class _Distance = ptrdiff_t> -class _LIBCPP_TYPE_VIS istream_iterator +class _LIBCPP_TYPE_VIS_ONLY istream_iterator : public iterator<input_iterator_tag, _Tp, _Distance, const _Tp*, const _Tp&> { public: @@ -760,7 +774,7 @@ public: }; template <class _Tp, class _CharT = char, class _Traits = char_traits<_CharT> > -class _LIBCPP_TYPE_VIS ostream_iterator +class _LIBCPP_TYPE_VIS_ONLY ostream_iterator : public iterator<output_iterator_tag, void, void, void, void> { public: @@ -789,7 +803,7 @@ public: }; template<class _CharT, class _Traits> -class _LIBCPP_TYPE_VIS istreambuf_iterator +class _LIBCPP_TYPE_VIS_ONLY istreambuf_iterator : public iterator<input_iterator_tag, _CharT, typename _Traits::off_type, _CharT*, _CharT> @@ -860,7 +874,7 @@ bool operator!=(const istreambuf_iterator<_CharT,_Traits>& __a, {return !__a.equal(__b);} template <class _CharT, class _Traits> -class _LIBCPP_TYPE_VIS ostreambuf_iterator +class _LIBCPP_TYPE_VIS_ONLY ostreambuf_iterator : public iterator<output_iterator_tag, void, void, void, void> { public: @@ -901,7 +915,7 @@ public: }; template <class _Iter> -class _LIBCPP_TYPE_VIS move_iterator +class _LIBCPP_TYPE_VIS_ONLY move_iterator { private: _Iter __i; @@ -1016,7 +1030,7 @@ operator+(typename move_iterator<_Iter>::difference_type __n, const move_iterato template <class _Iter> inline _LIBCPP_INLINE_VISIBILITY move_iterator<_Iter> -make_move_iterator(const _Iter& __i) +make_move_iterator(_Iter __i) { return move_iterator<_Iter>(__i); } @@ -1197,12 +1211,13 @@ public: _LIBCPP_INLINE_VISIBILITY iterator_type base() const _NOEXCEPT {return __i;} private: - _LIBCPP_INLINE_VISIBILITY __wrap_iter(iterator_type __x) _NOEXCEPT : __i(__x) {} #if _LIBCPP_DEBUG_LEVEL >= 2 _LIBCPP_INLINE_VISIBILITY __wrap_iter(const void* __p, iterator_type __x) : __i(__x) { __get_db()->__insert_ic(this, __p); } +#else + _LIBCPP_INLINE_VISIBILITY __wrap_iter(iterator_type __x) _NOEXCEPT : __i(__x) {} #endif template <class _Up> friend class __wrap_iter; @@ -1370,456 +1385,101 @@ operator+(typename __wrap_iter<_Iter>::difference_type __n, return __x; } -#ifdef _LIBCPP_DEBUG - -// __debug_iter - -template <class _Container, class _Iter> class __debug_iter; - -template <class _Container, class _Iter1, class _Iter2> -_LIBCPP_INLINE_VISIBILITY -bool -operator==(const __debug_iter<_Container, _Iter1>&, const __debug_iter<_Container, _Iter2>&); - -template <class _Container, class _Iter1, class _Iter2> -_LIBCPP_INLINE_VISIBILITY -bool -operator<(const __debug_iter<_Container, _Iter1>&, const __debug_iter<_Container, _Iter2>&); - -template <class _Container, class _Iter1, class _Iter2> -_LIBCPP_INLINE_VISIBILITY -bool -operator!=(const __debug_iter<_Container, _Iter1>&, const __debug_iter<_Container, _Iter2>&); - -template <class _Container, class _Iter1, class _Iter2> -_LIBCPP_INLINE_VISIBILITY -bool -operator>(const __debug_iter<_Container, _Iter1>&, const __debug_iter<_Container, _Iter2>&); - -template <class _Container, class _Iter1, class _Iter2> -_LIBCPP_INLINE_VISIBILITY -bool -operator>=(const __debug_iter<_Container, _Iter1>&, const __debug_iter<_Container, _Iter2>&); - -template <class _Container, class _Iter1, class _Iter2> -_LIBCPP_INLINE_VISIBILITY -bool -operator<=(const __debug_iter<_Container, _Iter1>&, const __debug_iter<_Container, _Iter2>&); - -template <class _Container, class _Iter1, class _Iter2> -_LIBCPP_INLINE_VISIBILITY -typename __debug_iter<_Container, _Iter1>::difference_type -operator-(const __debug_iter<_Container, _Iter1>&, const __debug_iter<_Container, _Iter2>&); - -template <class _Container, class _Iter> -_LIBCPP_INLINE_VISIBILITY -__debug_iter<_Container, _Iter> -operator+(typename __debug_iter<_Container, _Iter>::difference_type, const __debug_iter<_Container, _Iter>&); - -template <class _Container, class _Iter> -class __debug_iter -{ -public: - typedef _Iter iterator_type; - typedef _Container __container_type; - typedef typename iterator_traits<iterator_type>::iterator_category iterator_category; - typedef typename iterator_traits<iterator_type>::value_type value_type; - typedef typename iterator_traits<iterator_type>::difference_type difference_type; - typedef typename iterator_traits<iterator_type>::pointer pointer; - typedef typename iterator_traits<iterator_type>::reference reference; -private: - iterator_type __i; - __debug_iter* __next; - __container_type* __cont; - -public: - _LIBCPP_INLINE_VISIBILITY __debug_iter() : __next(0), __cont(0) {} - _LIBCPP_INLINE_VISIBILITY __debug_iter(const __debug_iter& __x) - : __i(__x.base()), __next(0), __cont(0) {__set_owner(__x.__cont);} - __debug_iter& operator=(const __debug_iter& __x); - template <class _Up> _LIBCPP_INLINE_VISIBILITY __debug_iter(const __debug_iter<_Container, _Up>& __u, - typename enable_if<is_convertible<_Up, iterator_type>::value>::type* = 0) - : __i(__u.base()), __next(0), __cont(0) {__set_owner(__u.__cont);} - _LIBCPP_INLINE_VISIBILITY ~__debug_iter() {__remove_owner();} - _LIBCPP_INLINE_VISIBILITY reference operator*() const {assert(__is_deref()); return *__i;} - _LIBCPP_INLINE_VISIBILITY pointer operator->() const {return &(operator*());} - _LIBCPP_INLINE_VISIBILITY __debug_iter& operator++() {assert(__can_increment()); ++__i; return *this;} - _LIBCPP_INLINE_VISIBILITY __debug_iter operator++(int) - {__debug_iter __tmp(*this); operator++(); return __tmp;} - _LIBCPP_INLINE_VISIBILITY __debug_iter& operator--() {assert(__can_decrement()); --__i; return *this;} - _LIBCPP_INLINE_VISIBILITY __debug_iter operator--(int) - {__debug_iter __tmp(*this); operator--(); return __tmp;} - _LIBCPP_INLINE_VISIBILITY __debug_iter operator+ (difference_type __n) const - {__debug_iter __t(*this); __t += __n; return __t;} - __debug_iter& operator+=(difference_type __n); - _LIBCPP_INLINE_VISIBILITY __debug_iter operator- (difference_type __n) const - {__debug_iter __t(*this); __t -= __n; return __t;} - _LIBCPP_INLINE_VISIBILITY __debug_iter& operator-=(difference_type __n) - {*this += -__n; return *this;} - _LIBCPP_INLINE_VISIBILITY reference operator[](difference_type __n) const - {return *(*this + __n);} - -private: - _LIBCPP_INLINE_VISIBILITY __debug_iter(const __container_type* __c, iterator_type __x) - : __i(__x), __next(0), __cont(0) {__set_owner(__c);} - _LIBCPP_INLINE_VISIBILITY iterator_type base() const {return __i;} - - void __set_owner(const __container_type* __c); - void __remove_owner(); - static void __remove_all(__container_type* __c); - static void swap(__container_type* __x, __container_type* __y); - - _LIBCPP_INLINE_VISIBILITY bool __is_deref() const - {return __is_deref(__is_random_access_iterator<iterator_type>());} - bool __is_deref(false_type) const; - bool __is_deref(true_type) const; - _LIBCPP_INLINE_VISIBILITY bool __can_decrement() const - {return __can_decrement(integral_constant<int, is_pointer<iterator_type>::value ? 2: - __is_random_access_iterator<iterator_type>::value ? 1 : 0>());} - bool __can_decrement(integral_constant<int, 0>) const; - bool __can_decrement(integral_constant<int, 1>) const; - bool __can_decrement(integral_constant<int, 2>) const; - _LIBCPP_INLINE_VISIBILITY bool __can_increment() const - {return __can_increment(integral_constant<int, is_pointer<iterator_type>::value ? 2: - __is_random_access_iterator<iterator_type>::value ? 1 : 0>());} - bool __can_increment(integral_constant<int, 0>) const; - bool __can_increment(integral_constant<int, 1>) const; - bool __can_increment(integral_constant<int, 2>) const; - - _LIBCPP_INLINE_VISIBILITY bool __can_add(difference_type __n) const - {return __can_add(__n, is_pointer<iterator_type>());} - bool __can_add(difference_type __n, false_type) const; - bool __can_add(difference_type __n, true_type) const; - - template <class _Cp, class _Up> friend class __debug_iter; - friend class _Container::__self; - - template <class _Cp, class _Iter1, class _Iter2> - friend - bool - operator==(const __debug_iter<_Cp, _Iter1>&, const __debug_iter<_Cp, _Iter2>&); - - template <class _Cp, class _Iter1, class _Iter2> - friend - bool - operator<(const __debug_iter<_Cp, _Iter1>&, const __debug_iter<_Cp, _Iter2>&); - - template <class _Cp, class _Iter1, class _Iter2> - friend - bool - operator!=(const __debug_iter<_Cp, _Iter1>&, const __debug_iter<_Cp, _Iter2>&); - - template <class _Cp, class _Iter1, class _Iter2> - friend - bool - operator>(const __debug_iter<_Cp, _Iter1>&, const __debug_iter<_Cp, _Iter2>&); - - template <class _Cp, class _Iter1, class _Iter2> - friend - bool - operator>=(const __debug_iter<_Cp, _Iter1>&, const __debug_iter<_Cp, _Iter2>&); - - template <class _Cp, class _Iter1, class _Iter2> - friend - bool - operator<=(const __debug_iter<_Cp, _Iter1>&, const __debug_iter<_Cp, _Iter2>&); - - template <class _Cp, class _Iter1, class _Iter2> - friend - typename __debug_iter<_Cp, _Iter1>::difference_type - operator-(const __debug_iter<_Cp, _Iter1>&, const __debug_iter<_Cp, _Iter2>&); - - template <class _Cp, class _Iter1> - friend - __debug_iter<_Cp, _Iter1> - operator+(typename __debug_iter<_Cp, _Iter1>::difference_type, const __debug_iter<_Cp, _Iter1>&); -}; - -template <class _Container, class _Iter> -__debug_iter<_Container, _Iter>& -__debug_iter<_Container, _Iter>::operator=(const __debug_iter& __x) -{ - if (this != &__x) - { - __remove_owner(); - __i = __x.__i; - __set_owner(__x.__cont); - } - return *this; -} - -template <class _Container, class _Iter> -void -__debug_iter<_Container, _Iter>::__set_owner(const __container_type* __c) -{ - __cont = const_cast<__container_type*>(__c); - __debug_iter*& __head = __cont->__get_iterator_list(this); - __next = __head; - __head = this; -} - -template <class _Container, class _Iter> -void -__debug_iter<_Container, _Iter>::__remove_owner() -{ - if (__cont) - { - __debug_iter*& __head = __cont->__get_iterator_list(this); - if (__head == this) - __head = __next; - else - { - __debug_iter* __prev = __head; - for (__debug_iter* __p = __head->__next; __p != this; __p = __p->__next) - __prev = __p; - __prev->__next = __next; - } - __cont = 0; - } -} - -template <class _Container, class _Iter> -void -__debug_iter<_Container, _Iter>::__remove_all(__container_type* __c) -{ - __debug_iter*& __head = __c->__get_iterator_list((__debug_iter*)0); - __debug_iter* __p = __head; - __head = 0; - while (__p) - { - __p->__cont = 0; - __debug_iter* __n = __p->__next; - __p->__next = 0; - __p = __n; - } -} - -template <class _Container, class _Iter> -void -__debug_iter<_Container, _Iter>::swap(__container_type* __x, __container_type* __y) -{ - __debug_iter*& __head_x = __x->__get_iterator_list((__debug_iter*)0); - __debug_iter*& __head_y = __y->__get_iterator_list((__debug_iter*)0); - __debug_iter* __p = __head_x; - __head_x = __head_y; - __head_y = __p; - for (__p = __head_x; __p; __p = __p->__next) - __p->__cont = __x; - for (__p = __head_y; __p; __p = __p->__next) - __p->__cont = __y; -} - -template <class _Container, class _Iter> -bool -__debug_iter<_Container, _Iter>::__is_deref(false_type) const -{ - if (__cont == 0) - return false; - return __i != __cont->end().base(); -} - -template <class _Container, class _Iter> -bool -__debug_iter<_Container, _Iter>::__is_deref(true_type) const -{ - if (__cont == 0) - return false; - return __i < __cont->end().base(); -} - -template <class _Container, class _Iter> -bool -__debug_iter<_Container, _Iter>::__can_decrement(integral_constant<int, 0>) const -{ - if (__cont == 0) - return false; - return __i != __cont->begin().base(); -} - -template <class _Container, class _Iter> -bool -__debug_iter<_Container, _Iter>::__can_decrement(integral_constant<int, 1>) const -{ - if (__cont == 0) - return false; - iterator_type __b = __cont->begin().base(); - return __b < __i && __i <= __b + __cont->size(); -} - -template <class _Container, class _Iter> -bool -__debug_iter<_Container, _Iter>::__can_decrement(integral_constant<int, 2>) const -{ - if (__cont == 0) - return false; - iterator_type __b = __cont->begin().base(); - return __b < __i && __i <= __b + __cont->size(); -} - -template <class _Container, class _Iter> -bool -__debug_iter<_Container, _Iter>::__can_increment(integral_constant<int, 0>) const -{ - if (__cont == 0) - return false; - return __i != __cont->end().base(); -} - -template <class _Container, class _Iter> -bool -__debug_iter<_Container, _Iter>::__can_increment(integral_constant<int, 1>) const -{ - if (__cont == 0) - return false; - iterator_type __b = __cont->begin().base(); - return __b <= __i && __i < __b + __cont->size(); -} - -template <class _Container, class _Iter> -bool -__debug_iter<_Container, _Iter>::__can_increment(integral_constant<int, 2>) const -{ - if (__cont == 0) - return false; - iterator_type __b = __cont->begin().base(); - return __b <= __i && __i < __b + __cont->size(); -} - -template <class _Container, class _Iter> -bool -__debug_iter<_Container, _Iter>::__can_add(difference_type __n, false_type) const -{ - if (__cont == 0) - return false; - iterator_type __b = __cont->begin().base(); - iterator_type __j = __i + __n; - return __b <= __j && __j <= __b + __cont->size(); -} - -template <class _Container, class _Iter> -bool -__debug_iter<_Container, _Iter>::__can_add(difference_type __n, true_type) const -{ - if (__cont == 0) - return false; - iterator_type __b = __cont->begin().base(); - iterator_type __j = __i + __n; - return __b <= __j && __j <= __b + __cont->size(); -} - -template <class _Container, class _Iter> -__debug_iter<_Container, _Iter>& -__debug_iter<_Container, _Iter>::operator+=(difference_type __n) -{ - assert(__can_add(__n)); - __i += __n; - return *this; -} +#if !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_TRAILING_RETURN) -template <class _Container, class _Iter1, class _Iter2> +template <class _Cp> inline _LIBCPP_INLINE_VISIBILITY -bool -operator==(const __debug_iter<_Container, _Iter1>& __x, const __debug_iter<_Container, _Iter2>& __y) +auto +begin(_Cp& __c) -> decltype(__c.begin()) { - assert(__x.__cont && __x.__cont == __y.__cont); - return __x.base() == __y.base(); + return __c.begin(); } -template <class _Container, class _Iter1, class _Iter2> +template <class _Cp> inline _LIBCPP_INLINE_VISIBILITY -bool -operator!=(const __debug_iter<_Container, _Iter1>& __x, const __debug_iter<_Container, _Iter2>& __y) +auto +begin(const _Cp& __c) -> decltype(__c.begin()) { - return !(__x == __y); + return __c.begin(); } -template <class _Container, class _Iter1, class _Iter2> +template <class _Cp> inline _LIBCPP_INLINE_VISIBILITY -bool -operator<(const __debug_iter<_Container, _Iter1>& __x, const __debug_iter<_Container, _Iter2>& __y) +auto +end(_Cp& __c) -> decltype(__c.end()) { - assert(__x.__cont && __x.__cont == __y.__cont); - return __x.base() < __y.base(); + return __c.end(); } -template <class _Container, class _Iter1, class _Iter2> +template <class _Cp> inline _LIBCPP_INLINE_VISIBILITY -bool -operator>(const __debug_iter<_Container, _Iter1>& __x, const __debug_iter<_Container, _Iter2>& __y) +auto +end(const _Cp& __c) -> decltype(__c.end()) { - return __y < __x; + return __c.end(); } -template <class _Container, class _Iter1, class _Iter2> +#if _LIBCPP_STD_VER > 11 + +template <class _Cp> inline _LIBCPP_INLINE_VISIBILITY -bool -operator>=(const __debug_iter<_Container, _Iter1>& __x, const __debug_iter<_Container, _Iter2>& __y) +auto cbegin(const _Cp& __c) -> decltype(begin(__c)) { - return !(__x < __y); + return __c.begin(); } -template <class _Container, class _Iter1, class _Iter2> +template <class _Cp> inline _LIBCPP_INLINE_VISIBILITY -bool -operator<=(const __debug_iter<_Container, _Iter1>& __x, const __debug_iter<_Container, _Iter2>& __y) +auto cend(const _Cp& __c) -> decltype(end(__c)) { - return !(__y < __x); + return __c.end(); } -template <class _Container, class _Iter1, class _Iter2> +template <class _Cp> inline _LIBCPP_INLINE_VISIBILITY -typename __debug_iter<_Container, _Iter1>::difference_type -operator-(const __debug_iter<_Container, _Iter1>& __x, const __debug_iter<_Container, _Iter2>& __y) +auto rbegin(_Cp& __c) -> decltype(__c.rbegin()) { - assert(__x.__cont && __x.__cont == __y.__cont); - return __x.base() - __y.base(); + return __c.rbegin(); } -template <class _Container, class _Iter> +template <class _Cp> inline _LIBCPP_INLINE_VISIBILITY -__debug_iter<_Container, _Iter> -operator+(typename __debug_iter<_Container, _Iter>::difference_type __n, - const __debug_iter<_Container, _Iter>& __x) +auto rbegin(const _Cp& __c) -> decltype(__c.rbegin()) { - return __x + __n; + return __c.rbegin(); } -#endif // _LIBCPP_DEBUG - -#if !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_TRAILING_RETURN) - template <class _Cp> inline _LIBCPP_INLINE_VISIBILITY -auto -begin(_Cp& __c) -> decltype(__c.begin()) +auto rend(_Cp& __c) -> decltype(__c.rend()) { - return __c.begin(); + return __c.rend(); } template <class _Cp> inline _LIBCPP_INLINE_VISIBILITY -auto -begin(const _Cp& __c) -> decltype(__c.begin()) +auto rend(const _Cp& __c) -> decltype(__c.rend()) { - return __c.begin(); + return __c.rend(); } template <class _Cp> inline _LIBCPP_INLINE_VISIBILITY -auto -end(_Cp& __c) -> decltype(__c.end()) +auto crbegin(const _Cp& __c) -> decltype(rbegin(__c)) { - return __c.end(); + return rbegin(__c); } template <class _Cp> inline _LIBCPP_INLINE_VISIBILITY -auto -end(const _Cp& __c) -> decltype(__c.end()) +auto crend(const _Cp& __c) -> decltype(rend(__c)) { - return __c.end(); + return rend(__c); } +#endif + + #else // !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_TRAILING_RETURN) template <class _Cp> @@ -1872,6 +1532,37 @@ end(_Tp (&__array)[_Np]) return __array + _Np; } +#if _LIBCPP_STD_VER > 11 +template <class _Tp, size_t _Np> +inline _LIBCPP_INLINE_VISIBILITY +reverse_iterator<_Tp*> rbegin(_Tp (&__array)[_Np]) +{ + return reverse_iterator<_Tp*>(__array + _Np); +} + +template <class _Tp, size_t _Np> +inline _LIBCPP_INLINE_VISIBILITY +reverse_iterator<_Tp*> rend(_Tp (&__array)[_Np]) +{ + return reverse_iterator<_Tp*>(__array); +} + +template <class _Ep> +inline _LIBCPP_INLINE_VISIBILITY +reverse_iterator<const _Ep*> rbegin(initializer_list<_Ep> __il) +{ + return reverse_iterator<const _Ep*>(__il.end()); +} + +template <class _Ep> +inline _LIBCPP_INLINE_VISIBILITY +reverse_iterator<const _Ep*> rend(initializer_list<_Ep> __il) +{ + return reverse_iterator<const _Ep*>(__il.begin()); +} + +#endif + _LIBCPP_END_NAMESPACE_STD #endif // _LIBCPP_ITERATOR |