diff options
author | Bruce Mitchener <bruce.mitchener@gmail.com> | 2013-02-17 14:29:14 +0700 |
---|---|---|
committer | Bruce Mitchener <bruce.mitchener@gmail.com> | 2013-03-25 00:34:11 +0700 |
commit | 59ff5a6a3c3e1f5255c5cf29f98df633a77b89b3 (patch) | |
tree | c7660fa62600366e3479dbf6b2fd1d25709af1b5 /system/include/libcxx/iterator | |
parent | 80fd6f0bce2b95db6ec539c9275ce24585550e7c (diff) |
Update to current libcxx.
This doesn't work yet as it needs to be customized for use with
emscripten still.
Diffstat (limited to 'system/include/libcxx/iterator')
-rw-r--r-- | system/include/libcxx/iterator | 217 |
1 files changed, 142 insertions, 75 deletions
diff --git a/system/include/libcxx/iterator b/system/include/libcxx/iterator index 05019fdd..b23310b0 100644 --- a/system/include/libcxx/iterator +++ b/system/include/libcxx/iterator @@ -263,10 +263,10 @@ public: typedef basic_streambuf<charT,traits> streambuf_type; typedef basic_istream<charT,traits> istream_type; - istreambuf_iterator() throw(); - istreambuf_iterator(istream_type& s) throw(); - istreambuf_iterator(streambuf_type* s) throw(); - istreambuf_iterator(a-private-type) throw(); + istreambuf_iterator() noexcept; + istreambuf_iterator(istream_type& s) noexcept; + istreambuf_iterator(streambuf_type* s) noexcept; + istreambuf_iterator(a-private-type) noexcept; charT operator*() const; pointer operator->() const; @@ -293,13 +293,13 @@ public: typedef basic_streambuf<charT,traits> streambuf_type; typedef basic_ostream<charT,traits> ostream_type; - ostreambuf_iterator(ostream_type& s) throw(); - ostreambuf_iterator(streambuf_type* s) throw(); + ostreambuf_iterator(ostream_type& s) noexcept; + ostreambuf_iterator(streambuf_type* s) noexcept; ostreambuf_iterator& operator=(charT c); ostreambuf_iterator& operator*(); ostreambuf_iterator& operator++(); ostreambuf_iterator& operator++(int); - bool failed() const throw(); + bool failed() const noexcept; }; template <class C> auto begin(C& c) -> decltype(c.begin()); @@ -317,11 +317,17 @@ template <class T, size_t N> T* end(T (&array)[N]); #include <type_traits> #include <cstddef> #include <iosfwd> +#if __APPLE__ +#include <Availability.h> +#endif + #ifdef _LIBCPP_DEBUG #include <cassert> #endif +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header +#endif _LIBCPP_BEGIN_NAMESPACE_STD @@ -335,7 +341,7 @@ template <class _Tp> struct __has_iterator_category { private: - struct __two {char _; char __;}; + struct __two {char __lx; char __lxx;}; template <class _Up> static __two __test(...); template <class _Up> static char __test(typename _Up::iterator_category* = 0); public: @@ -624,11 +630,11 @@ public: typedef _Container container_type; _LIBCPP_INLINE_VISIBILITY explicit back_insert_iterator(_Container& __x) : container(&__x) {} - _LIBCPP_INLINE_VISIBILITY back_insert_iterator& operator=(const typename _Container::value_type& __value) - {container->push_back(__value); return *this;} + _LIBCPP_INLINE_VISIBILITY back_insert_iterator& operator=(const typename _Container::value_type& __value_) + {container->push_back(__value_); return *this;} #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES - _LIBCPP_INLINE_VISIBILITY back_insert_iterator& operator=(typename _Container::value_type&& __value) - {container->push_back(_VSTD::move(__value)); return *this;} + _LIBCPP_INLINE_VISIBILITY back_insert_iterator& operator=(typename _Container::value_type&& __value_) + {container->push_back(_VSTD::move(__value_)); return *this;} #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES _LIBCPP_INLINE_VISIBILITY back_insert_iterator& operator*() {return *this;} _LIBCPP_INLINE_VISIBILITY back_insert_iterator& operator++() {return *this;} @@ -657,11 +663,11 @@ public: typedef _Container container_type; _LIBCPP_INLINE_VISIBILITY explicit front_insert_iterator(_Container& __x) : container(&__x) {} - _LIBCPP_INLINE_VISIBILITY front_insert_iterator& operator=(const typename _Container::value_type& __value) - {container->push_front(__value); return *this;} + _LIBCPP_INLINE_VISIBILITY front_insert_iterator& operator=(const typename _Container::value_type& __value_) + {container->push_front(__value_); return *this;} #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES - _LIBCPP_INLINE_VISIBILITY front_insert_iterator& operator=(typename _Container::value_type&& __value) - {container->push_front(_VSTD::move(__value)); return *this;} + _LIBCPP_INLINE_VISIBILITY front_insert_iterator& operator=(typename _Container::value_type&& __value_) + {container->push_front(_VSTD::move(__value_)); return *this;} #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES _LIBCPP_INLINE_VISIBILITY front_insert_iterator& operator*() {return *this;} _LIBCPP_INLINE_VISIBILITY front_insert_iterator& operator++() {return *this;} @@ -692,11 +698,11 @@ public: _LIBCPP_INLINE_VISIBILITY insert_iterator(_Container& __x, typename _Container::iterator __i) : container(&__x), iter(__i) {} - _LIBCPP_INLINE_VISIBILITY insert_iterator& operator=(const typename _Container::value_type& __value) - {iter = container->insert(iter, __value); ++iter; return *this;} + _LIBCPP_INLINE_VISIBILITY insert_iterator& operator=(const typename _Container::value_type& __value_) + {iter = container->insert(iter, __value_); ++iter; return *this;} #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES - _LIBCPP_INLINE_VISIBILITY insert_iterator& operator=(typename _Container::value_type&& __value) - {iter = container->insert(iter, _VSTD::move(__value)); ++iter; return *this;} + _LIBCPP_INLINE_VISIBILITY insert_iterator& operator=(typename _Container::value_type&& __value_) + {iter = container->insert(iter, _VSTD::move(__value_)); ++iter; return *this;} #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES _LIBCPP_INLINE_VISIBILITY insert_iterator& operator*() {return *this;} _LIBCPP_INLINE_VISIBILITY insert_iterator& operator++() {return *this;} @@ -767,9 +773,9 @@ public: : __out_stream_(&__s), __delim_(0) {} _LIBCPP_INLINE_VISIBILITY ostream_iterator(ostream_type& __s, const _CharT* __delimiter) : __out_stream_(&__s), __delim_(__delimiter) {} - _LIBCPP_INLINE_VISIBILITY ostream_iterator& operator=(const _Tp& __value) + _LIBCPP_INLINE_VISIBILITY ostream_iterator& operator=(const _Tp& __value_) { - *__out_stream_ << __value; + *__out_stream_ << __value_; if (__delim_) *__out_stream_ << __delim_; return *this; @@ -793,7 +799,7 @@ public: typedef basic_streambuf<_CharT,_Traits> streambuf_type; typedef basic_istream<_CharT,_Traits> istream_type; private: - streambuf_type* __sbuf_; + mutable streambuf_type* __sbuf_; class __proxy { @@ -807,37 +813,36 @@ private: }; _LIBCPP_INLINE_VISIBILITY - void __test_for_eof() + bool __test_for_eof() const { if (__sbuf_ && traits_type::eq_int_type(__sbuf_->sgetc(), traits_type::eof())) __sbuf_ = 0; + return __sbuf_ == 0; } public: - _LIBCPP_INLINE_VISIBILITY istreambuf_iterator() throw() : __sbuf_(0) {} - _LIBCPP_INLINE_VISIBILITY istreambuf_iterator(istream_type& __s) throw() - : __sbuf_(__s.rdbuf()) {__test_for_eof();} - _LIBCPP_INLINE_VISIBILITY istreambuf_iterator(streambuf_type* __s) throw() - : __sbuf_(__s) {__test_for_eof();} - _LIBCPP_INLINE_VISIBILITY istreambuf_iterator(const __proxy& __p) throw() + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR istreambuf_iterator() _NOEXCEPT : __sbuf_(0) {} + _LIBCPP_INLINE_VISIBILITY istreambuf_iterator(istream_type& __s) _NOEXCEPT + : __sbuf_(__s.rdbuf()) {} + _LIBCPP_INLINE_VISIBILITY istreambuf_iterator(streambuf_type* __s) _NOEXCEPT + : __sbuf_(__s) {} + _LIBCPP_INLINE_VISIBILITY istreambuf_iterator(const __proxy& __p) _NOEXCEPT : __sbuf_(__p.__sbuf_) {} - _LIBCPP_INLINE_VISIBILITY _CharT operator*() const {return __sbuf_->sgetc();} + _LIBCPP_INLINE_VISIBILITY char_type operator*() const + {return static_cast<char_type>(__sbuf_->sgetc());} _LIBCPP_INLINE_VISIBILITY char_type* operator->() const {return nullptr;} _LIBCPP_INLINE_VISIBILITY istreambuf_iterator& operator++() { - if (traits_type::eq_int_type(__sbuf_->snextc(), traits_type::eof())) - __sbuf_ = 0; + __sbuf_->sbumpc(); return *this; } _LIBCPP_INLINE_VISIBILITY __proxy operator++(int) { - char_type __c = __sbuf_->sgetc(); - ++(*this); - return __proxy(__c, __sbuf_); + return __proxy(__sbuf_->sbumpc(), __sbuf_); } _LIBCPP_INLINE_VISIBILITY bool equal(const istreambuf_iterator& __b) const - {return (__sbuf_ == 0) == (__b.__sbuf_ == 0);} + {return __test_for_eof() == __b.__test_for_eof();} }; template <class _CharT, class _Traits> @@ -864,9 +869,9 @@ public: private: streambuf_type* __sbuf_; public: - _LIBCPP_INLINE_VISIBILITY ostreambuf_iterator(ostream_type& __s) throw() + _LIBCPP_INLINE_VISIBILITY ostreambuf_iterator(ostream_type& __s) _NOEXCEPT : __sbuf_(__s.rdbuf()) {} - _LIBCPP_INLINE_VISIBILITY ostreambuf_iterator(streambuf_type* __s) throw() + _LIBCPP_INLINE_VISIBILITY ostreambuf_iterator(streambuf_type* __s) _NOEXCEPT : __sbuf_(__s) {} _LIBCPP_INLINE_VISIBILITY ostreambuf_iterator& operator=(_CharT __c) { @@ -877,7 +882,20 @@ public: _LIBCPP_INLINE_VISIBILITY ostreambuf_iterator& operator*() {return *this;} _LIBCPP_INLINE_VISIBILITY ostreambuf_iterator& operator++() {return *this;} _LIBCPP_INLINE_VISIBILITY ostreambuf_iterator& operator++(int) {return *this;} - _LIBCPP_INLINE_VISIBILITY bool failed() const throw() {return __sbuf_ == 0;} + _LIBCPP_INLINE_VISIBILITY bool failed() const _NOEXCEPT {return __sbuf_ == 0;} + +#if !defined(__APPLE__) || \ + (defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED > __MAC_10_8) || \ + (defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && __IPHONE_OS_VERSION_MIN_REQUIRED > __IPHONE_6_0) + + template <class _Ch, class _Tr> + friend + _LIBCPP_HIDDEN + ostreambuf_iterator<_Ch, _Tr> + __pad_and_output(ostreambuf_iterator<_Ch, _Tr> __s, + const _Ch* __ob, const _Ch* __op, const _Ch* __oe, + ios_base& __iob, _Ch __fl); +#endif }; template <class _Iter> @@ -1006,43 +1024,52 @@ make_move_iterator(const _Iter& __i) template <class _Iter> class __wrap_iter; template <class _Iter1, class _Iter2> +_LIBCPP_INLINE_VISIBILITY bool operator==(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) _NOEXCEPT; template <class _Iter1, class _Iter2> +_LIBCPP_INLINE_VISIBILITY bool operator<(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) _NOEXCEPT; template <class _Iter1, class _Iter2> +_LIBCPP_INLINE_VISIBILITY bool operator!=(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) _NOEXCEPT; template <class _Iter1, class _Iter2> +_LIBCPP_INLINE_VISIBILITY bool operator>(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) _NOEXCEPT; template <class _Iter1, class _Iter2> +_LIBCPP_INLINE_VISIBILITY bool operator>=(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) _NOEXCEPT; template <class _Iter1, class _Iter2> +_LIBCPP_INLINE_VISIBILITY bool operator<=(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) _NOEXCEPT; template <class _Iter1, class _Iter2> +_LIBCPP_INLINE_VISIBILITY typename __wrap_iter<_Iter1>::difference_type operator-(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) _NOEXCEPT; template <class _Iter> +_LIBCPP_INLINE_VISIBILITY __wrap_iter<_Iter> -operator+(typename __wrap_iter<_Iter>::difference_type, const __wrap_iter<_Iter>&) _NOEXCEPT; +operator+(typename __wrap_iter<_Iter>::difference_type, __wrap_iter<_Iter>) _NOEXCEPT; -template <class _I, class _O> _O copy(_I, _I, _O); -template <class _B1, class _B2> _B2 copy_backward(_B1, _B1, _B2); -template <class _I, class _O> _O move(_I, _I, _O); -template <class _B1, class _B2> _B2 move_backward(_B1, _B1, _B2); +template <class _Ip, class _Op> _Op _LIBCPP_INLINE_VISIBILITY copy(_Ip, _Ip, _Op); +template <class _B1, class _B2> _B2 _LIBCPP_INLINE_VISIBILITY copy_backward(_B1, _B1, _B2); +template <class _Ip, class _Op> _Op _LIBCPP_INLINE_VISIBILITY move(_Ip, _Ip, _Op); +template <class _B1, class _B2> _B2 _LIBCPP_INLINE_VISIBILITY move_backward(_B1, _B1, _B2); template <class _Tp> +_LIBCPP_INLINE_VISIBILITY typename enable_if < is_trivially_copy_assignable<_Tp>::value, @@ -1208,11 +1235,11 @@ private: template <class _Iter1> friend __wrap_iter<_Iter1> - operator+(typename __wrap_iter<_Iter1>::difference_type, const __wrap_iter<_Iter1>&) _NOEXCEPT; + operator+(typename __wrap_iter<_Iter1>::difference_type, __wrap_iter<_Iter1>) _NOEXCEPT; - template <class _I, class _O> friend _O copy(_I, _I, _O); + template <class _Ip, class _Op> friend _Op copy(_Ip, _Ip, _Op); template <class _B1, class _B2> friend _B2 copy_backward(_B1, _B1, _B2); - template <class _I, class _O> friend _O move(_I, _I, _O); + template <class _Ip, class _Op> friend _Op move(_Ip, _Ip, _Op); template <class _B1, class _B2> friend _B2 move_backward(_B1, _B1, _B2); template <class _Tp> @@ -1281,6 +1308,38 @@ operator<=(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEX return !(__y < __x); } +template <class _Iter1> +inline _LIBCPP_INLINE_VISIBILITY +bool +operator!=(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter1>& __y) _NOEXCEPT +{ + return !(__x == __y); +} + +template <class _Iter1> +inline _LIBCPP_INLINE_VISIBILITY +bool +operator>(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter1>& __y) _NOEXCEPT +{ + return __y < __x; +} + +template <class _Iter1> +inline _LIBCPP_INLINE_VISIBILITY +bool +operator>=(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter1>& __y) _NOEXCEPT +{ + return !(__x < __y); +} + +template <class _Iter1> +inline _LIBCPP_INLINE_VISIBILITY +bool +operator<=(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter1>& __y) _NOEXCEPT +{ + return !(__y < __x); +} + template <class _Iter1, class _Iter2> inline _LIBCPP_INLINE_VISIBILITY typename __wrap_iter<_Iter1>::difference_type @@ -1310,34 +1369,42 @@ operator+(typename __wrap_iter<_Iter>::difference_type __n, 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>&); @@ -1713,88 +1780,88 @@ operator+(typename __debug_iter<_Container, _Iter>::difference_type __n, #if !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_TRAILING_RETURN) -template <class _C> +template <class _Cp> inline _LIBCPP_INLINE_VISIBILITY auto -begin(_C& __c) -> decltype(__c.begin()) +begin(_Cp& __c) -> decltype(__c.begin()) { return __c.begin(); } -template <class _C> +template <class _Cp> inline _LIBCPP_INLINE_VISIBILITY auto -begin(const _C& __c) -> decltype(__c.begin()) +begin(const _Cp& __c) -> decltype(__c.begin()) { return __c.begin(); } -template <class _C> +template <class _Cp> inline _LIBCPP_INLINE_VISIBILITY auto -end(_C& __c) -> decltype(__c.end()) +end(_Cp& __c) -> decltype(__c.end()) { return __c.end(); } -template <class _C> +template <class _Cp> inline _LIBCPP_INLINE_VISIBILITY auto -end(const _C& __c) -> decltype(__c.end()) +end(const _Cp& __c) -> decltype(__c.end()) { return __c.end(); } #else // !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_TRAILING_RETURN) -template <class _C> +template <class _Cp> inline _LIBCPP_INLINE_VISIBILITY -typename _C::iterator -begin(_C& __c) +typename _Cp::iterator +begin(_Cp& __c) { return __c.begin(); } -template <class _C> +template <class _Cp> inline _LIBCPP_INLINE_VISIBILITY -typename _C::const_iterator -begin(const _C& __c) +typename _Cp::const_iterator +begin(const _Cp& __c) { return __c.begin(); } -template <class _C> +template <class _Cp> inline _LIBCPP_INLINE_VISIBILITY -typename _C::iterator -end(_C& __c) +typename _Cp::iterator +end(_Cp& __c) { return __c.end(); } -template <class _C> +template <class _Cp> inline _LIBCPP_INLINE_VISIBILITY -typename _C::const_iterator -end(const _C& __c) +typename _Cp::const_iterator +end(const _Cp& __c) { return __c.end(); } #endif // !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_TRAILING_RETURN) -template <class _T, size_t _N> +template <class _Tp, size_t _Np> inline _LIBCPP_INLINE_VISIBILITY -_T* -begin(_T (&__array)[_N]) +_Tp* +begin(_Tp (&__array)[_Np]) { return __array; } -template <class _T, size_t _N> +template <class _Tp, size_t _Np> inline _LIBCPP_INLINE_VISIBILITY -_T* -end(_T (&__array)[_N]) +_Tp* +end(_Tp (&__array)[_Np]) { - return __array + _N; + return __array + _Np; } _LIBCPP_END_NAMESPACE_STD |