diff options
Diffstat (limited to 'libstdc++-v3/include/debug/list')
-rw-r--r-- | libstdc++-v3/include/debug/list | 136 |
1 files changed, 118 insertions, 18 deletions
diff --git a/libstdc++-v3/include/debug/list b/libstdc++-v3/include/debug/list index 939fe4da48d..b071d4fcdd6 100644 --- a/libstdc++-v3/include/debug/list +++ b/libstdc++-v3/include/debug/list @@ -1,6 +1,6 @@ // Debugging list implementation -*- C++ -*- -// Copyright (C) 2003, 2004, 2005, 2006 +// Copyright (C) 2003, 2004, 2005, 2006, 2007 // Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free @@ -73,10 +73,10 @@ namespace __debug { template<typename _Tp, typename _Allocator = std::allocator<_Tp> > class list - : public _GLIBCXX_STD::list<_Tp, _Allocator>, + : public _GLIBCXX_STD_D::list<_Tp, _Allocator>, public __gnu_debug::_Safe_sequence<list<_Tp, _Allocator> > { - typedef _GLIBCXX_STD::list<_Tp, _Allocator> _Base; + typedef _GLIBCXX_STD_D::list<_Tp, _Allocator> _Base; typedef __gnu_debug::_Safe_sequence<list> _Safe_base; public: @@ -113,9 +113,17 @@ namespace __debug { } - list(const list& __x) : _Base(__x), _Safe_base() { } + list(const list& __x) + : _Base(__x), _Safe_base() { } - list(const _Base& __x) : _Base(__x), _Safe_base() { } + list(const _Base& __x) + : _Base(__x), _Safe_base() { } + +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + list(list&& __x) + : _Base(std::forward<list>(__x)), _Safe_base() + { this->_M_swap(__x); } +#endif ~list() { } @@ -127,6 +135,17 @@ namespace __debug return *this; } +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + list& + operator=(list&& __x) + { + // NB: DR 675. + clear(); + swap(__x); + return *this; + } +#endif + template<class _InputIterator> void assign(_InputIterator __first, _InputIterator __last) @@ -178,6 +197,24 @@ namespace __debug rend() const { return const_reverse_iterator(begin()); } +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + const_iterator + cbegin() const + { return const_iterator(_Base::begin(), this); } + + const_iterator + cend() const + { return const_iterator(_Base::end(), this); } + + const_reverse_iterator + crbegin() const + { return const_reverse_iterator(end()); } + + const_reverse_iterator + crend() const + { return const_reverse_iterator(begin()); } +#endif + // 23.2.2.2 capacity: using _Base::empty; using _Base::size; @@ -264,6 +301,17 @@ namespace __debug _Base::pop_back(); } +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + template<typename... _Args> + iterator + emplace(iterator __position, _Args&&... __args) + { + __glibcxx_check_insert(__position); + return iterator(_Base::emplace(__position.base(), + std::forward<_Args>(__args)...), this); + } +#endif + iterator insert(iterator __position, const _Tp& __x) { @@ -271,6 +319,12 @@ namespace __debug return iterator(_Base::insert(__position.base(), __x), this); } +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + iterator + insert(iterator __position, _Tp&& __x) + { return emplace(__position, std::move(__x)); } +#endif + void insert(iterator __position, size_type __n, const _Tp& __x) { @@ -311,7 +365,11 @@ namespace __debug } void +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + swap(list&& __x) +#else swap(list& __x) +#endif { _Base::swap(__x); this->_M_swap(__x); @@ -326,16 +384,24 @@ namespace __debug // 23.2.2.4 list operations: void +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + splice(iterator __position, list&& __x) +#else splice(iterator __position, list& __x) +#endif { _GLIBCXX_DEBUG_VERIFY(&__x != this, _M_message(__gnu_debug::__msg_self_splice) ._M_sequence(*this, "this")); - this->splice(__position, __x, __x.begin(), __x.end()); + this->splice(__position, _GLIBCXX_MOVE(__x), __x.begin(), __x.end()); } void +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + splice(iterator __position, list&& __x, iterator __i) +#else splice(iterator __position, list& __x, iterator __i) +#endif { __glibcxx_check_insert(__position); @@ -352,11 +418,18 @@ namespace __debug // _GLIBCXX_RESOLVE_LIB_DEFECTS // 250. splicing invalidates iterators this->_M_transfer_iter(__i); - _Base::splice(__position.base(), __x._M_base(), __i.base()); + _Base::splice(__position.base(), _GLIBCXX_MOVE(__x._M_base()), + __i.base()); } void - splice(iterator __position, list& __x, iterator __first, iterator __last) +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + splice(iterator __position, list&& __x, iterator __first, + iterator __last) +#else + splice(iterator __position, list& __x, iterator __first, + iterator __last) +#endif { __glibcxx_check_insert(__position); __glibcxx_check_valid_range(__first, __last); @@ -381,8 +454,8 @@ namespace __debug this->_M_transfer_iter(__victim); } - _Base::splice(__position.base(), __x._M_base(), __first.base(), - __last.base()); + _Base::splice(__position.base(), _GLIBCXX_MOVE(__x._M_base()), + __first.base(), __last.base()); } void @@ -448,7 +521,11 @@ namespace __debug } void +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + merge(list&& __x) +#else merge(list& __x) +#endif { __glibcxx_check_sorted(_Base::begin(), _Base::end()); __glibcxx_check_sorted(__x.begin().base(), __x.end().base()); @@ -457,12 +534,16 @@ namespace __debug iterator __victim = __tmp++; __victim._M_attach(&__x); } - _Base::merge(__x._M_base()); + _Base::merge(_GLIBCXX_MOVE(__x._M_base())); } template<class _Compare> void +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + merge(list&& __x, _Compare __comp) +#else merge(list& __x, _Compare __comp) +#endif { __glibcxx_check_sorted_pred(_Base::begin(), _Base::end(), __comp); __glibcxx_check_sorted_pred(__x.begin().base(), __x.end().base(), @@ -472,7 +553,7 @@ namespace __debug iterator __victim = __tmp++; __victim._M_attach(&__x); } - _Base::merge(__x._M_base(), __comp); + _Base::merge(_GLIBCXX_MOVE(__x._M_base()), __comp); } void @@ -502,38 +583,57 @@ namespace __debug template<typename _Tp, typename _Alloc> inline bool - operator==(const list<_Tp, _Alloc>& __lhs, const list<_Tp, _Alloc>& __rhs) + operator==(const list<_Tp, _Alloc>& __lhs, + const list<_Tp, _Alloc>& __rhs) { return __lhs._M_base() == __rhs._M_base(); } template<typename _Tp, typename _Alloc> inline bool - operator!=(const list<_Tp, _Alloc>& __lhs, const list<_Tp, _Alloc>& __rhs) + operator!=(const list<_Tp, _Alloc>& __lhs, + const list<_Tp, _Alloc>& __rhs) { return __lhs._M_base() != __rhs._M_base(); } template<typename _Tp, typename _Alloc> inline bool - operator<(const list<_Tp, _Alloc>& __lhs, const list<_Tp, _Alloc>& __rhs) + operator<(const list<_Tp, _Alloc>& __lhs, + const list<_Tp, _Alloc>& __rhs) { return __lhs._M_base() < __rhs._M_base(); } template<typename _Tp, typename _Alloc> inline bool - operator<=(const list<_Tp, _Alloc>& __lhs, const list<_Tp, _Alloc>& __rhs) + operator<=(const list<_Tp, _Alloc>& __lhs, + const list<_Tp, _Alloc>& __rhs) { return __lhs._M_base() <= __rhs._M_base(); } template<typename _Tp, typename _Alloc> inline bool - operator>=(const list<_Tp, _Alloc>& __lhs, const list<_Tp, _Alloc>& __rhs) + operator>=(const list<_Tp, _Alloc>& __lhs, + const list<_Tp, _Alloc>& __rhs) { return __lhs._M_base() >= __rhs._M_base(); } template<typename _Tp, typename _Alloc> inline bool - operator>(const list<_Tp, _Alloc>& __lhs, const list<_Tp, _Alloc>& __rhs) + operator>(const list<_Tp, _Alloc>& __lhs, + const list<_Tp, _Alloc>& __rhs) { return __lhs._M_base() > __rhs._M_base(); } template<typename _Tp, typename _Alloc> inline void swap(list<_Tp, _Alloc>& __lhs, list<_Tp, _Alloc>& __rhs) { __lhs.swap(__rhs); } + +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + template<typename _Tp, typename _Alloc> + inline void + swap(list<_Tp, _Alloc>&& __lhs, list<_Tp, _Alloc>& __rhs) + { __lhs.swap(__rhs); } + + template<typename _Tp, typename _Alloc> + inline void + swap(list<_Tp, _Alloc>& __lhs, list<_Tp, _Alloc>&& __rhs) + { __lhs.swap(__rhs); } +#endif + } // namespace __debug } // namespace std |