diff options
| author | Marshall Clow <mclow.lists@gmail.com> | 2013-08-30 01:17:07 +0000 |
|---|---|---|
| committer | Marshall Clow <mclow.lists@gmail.com> | 2013-08-30 01:17:07 +0000 |
| commit | 1e548c72e70ed4c3c4f6ebe2ff76f15b9fd27c5a (patch) | |
| tree | 56d080c9185b0bfe1bdb0a8a1a3d6b168c5d3ff5 /libcxx/include/iterator | |
| parent | 531cd4b278f98bca83554311161d3c2107bb1264 (diff) | |
| download | bcm5719-llvm-1e548c72e70ed4c3c4f6ebe2ff76f15b9fd27c5a.tar.gz bcm5719-llvm-1e548c72e70ed4c3c4f6ebe2ff76f15b9fd27c5a.zip | |
LWG Issue 2128: Implement global cbegin/rbegin/cend/rbegin
llvm-svn: 189634
Diffstat (limited to 'libcxx/include/iterator')
| -rw-r--r-- | libcxx/include/iterator | 106 |
1 files changed, 106 insertions, 0 deletions
diff --git a/libcxx/include/iterator b/libcxx/include/iterator index 979a9645f7e..d16aa2aa95f 100644 --- a/libcxx/include/iterator +++ b/libcxx/include/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,6 +330,7 @@ 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 @@ -1405,6 +1419,67 @@ end(const _Cp& __c) -> decltype(__c.end()) return __c.end(); } +#if _LIBCPP_STD_VER > 11 + +template <class _Cp> +inline _LIBCPP_INLINE_VISIBILITY +auto cbegin(const _Cp& __c) -> decltype(begin(__c)) +{ + return __c.begin(); +} + +template <class _Cp> +inline _LIBCPP_INLINE_VISIBILITY +auto cend(const _Cp& __c) -> decltype(end(__c)) +{ + return __c.end(); +} + +template <class _Cp> +inline _LIBCPP_INLINE_VISIBILITY +auto rbegin(_Cp& __c) -> decltype(__c.rbegin()) +{ + return __c.rbegin(); +} + +template <class _Cp> +inline _LIBCPP_INLINE_VISIBILITY +auto rbegin(const _Cp& __c) -> decltype(__c.rbegin()) +{ + return __c.rbegin(); +} + +template <class _Cp> +inline _LIBCPP_INLINE_VISIBILITY +auto rend(_Cp& __c) -> decltype(__c.rend()) +{ + return __c.rend(); +} + +template <class _Cp> +inline _LIBCPP_INLINE_VISIBILITY +auto rend(const _Cp& __c) -> decltype(__c.rend()) +{ + return __c.rend(); +} + +template <class _Cp> +inline _LIBCPP_INLINE_VISIBILITY +auto crbegin(const _Cp& __c) -> decltype(rbegin(__c)) +{ + return rbegin(__c); +} + +template <class _Cp> +inline _LIBCPP_INLINE_VISIBILITY +auto crend(const _Cp& __c) -> decltype(rend(__c)) +{ + return rend(__c); +} + +#endif + + #else // !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_TRAILING_RETURN) template <class _Cp> @@ -1457,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 |

