Commit b4efa80e by Marc Glisse Committed by Marc Glisse

re PR libstdc++/58338 (Add noexcept to functions with a narrow contract)

2013-09-18  Marc Glisse  <marc.glisse@inria.fr>

	PR libstdc++/58338
	* include/bits/stl_iterator.h (__normal_iterator) [__normal_iterator,
	_M_const_cast, operator*, operator->, operator++, operator--,
	operator[], operator+=, operator+, operator-=, operator-, base]:
	Mark as noexcept.
	(operator==(const __normal_iterator&, const __normal_iterator&),
	operator!=(const __normal_iterator&, const __normal_iterator&),
	operator<(const __normal_iterator&, const __normal_iterator&),
	operator>(const __normal_iterator&, const __normal_iterator&),
	operator<=(const __normal_iterator&, const __normal_iterator&),
	operator>=(const __normal_iterator&, const __normal_iterator&),
	operator-(const __normal_iterator&, const __normal_iterator&),
	operator+(difference_type, const __normal_iterator&)): Likewise.
	* include/bits/stl_list.h (list) [splice, _M_check_equal_allocators]:
	Likewise.
	(list::_M_check_equal_allocators): Abort instead of throwing.
	* include/debug/array (array) [operator[], front, back]: Mark as
	noexcept.
	* include/profile/array (array) [operator[], front, back]: Likewise.
	* include/std/array (array) [operator[], front, back]: Likewise.
	* include/debug/list (list::splice): Likewise.
	* include/profile/list (list::splice): Likewise.
	* testsuite/23_containers/list/operations/5.cc: Remove file.
	* testsuite/23_containers/list/operations/5.h: Likewise.

From-SVN: r202716
parent c9b29b25
2013-09-18 Marc Glisse <marc.glisse@inria.fr>
PR libstdc++/58338
* include/bits/stl_iterator.h (__normal_iterator) [__normal_iterator,
_M_const_cast, operator*, operator->, operator++, operator--,
operator[], operator+=, operator+, operator-=, operator-, base]:
Mark as noexcept.
(operator==(const __normal_iterator&, const __normal_iterator&),
operator!=(const __normal_iterator&, const __normal_iterator&),
operator<(const __normal_iterator&, const __normal_iterator&),
operator>(const __normal_iterator&, const __normal_iterator&),
operator<=(const __normal_iterator&, const __normal_iterator&),
operator>=(const __normal_iterator&, const __normal_iterator&),
operator-(const __normal_iterator&, const __normal_iterator&),
operator+(difference_type, const __normal_iterator&)): Likewise.
* include/bits/stl_list.h (list) [splice, _M_check_equal_allocators]:
Likewise.
(list::_M_check_equal_allocators): Abort instead of throwing.
* include/debug/array (array) [operator[], front, back]: Mark as
noexcept.
* include/profile/array (array) [operator[], front, back]: Likewise.
* include/std/array (array) [operator[], front, back]: Likewise.
* include/debug/list (list::splice): Likewise.
* include/profile/list (list::splice): Likewise.
* testsuite/23_containers/list/operations/5.cc: Remove file.
* testsuite/23_containers/list/operations/5.h: Likewise.
2013-09-18 Tim Shen <timshen91@gmail.com> 2013-09-18 Tim Shen <timshen91@gmail.com>
* include/bits/regex.h: Add friend classes. * include/bits/regex.h: Add friend classes.
......
...@@ -721,22 +721,24 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -721,22 +721,24 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
typedef typename __traits_type::reference reference; typedef typename __traits_type::reference reference;
typedef typename __traits_type::pointer pointer; typedef typename __traits_type::pointer pointer;
_GLIBCXX_CONSTEXPR __normal_iterator() : _M_current(_Iterator()) { } _GLIBCXX_CONSTEXPR __normal_iterator() _GLIBCXX_NOEXCEPT
: _M_current(_Iterator()) { }
explicit explicit
__normal_iterator(const _Iterator& __i) : _M_current(__i) { } __normal_iterator(const _Iterator& __i) _GLIBCXX_NOEXCEPT
: _M_current(__i) { }
// Allow iterator to const_iterator conversion // Allow iterator to const_iterator conversion
template<typename _Iter> template<typename _Iter>
__normal_iterator(const __normal_iterator<_Iter, __normal_iterator(const __normal_iterator<_Iter,
typename __enable_if< typename __enable_if<
(std::__are_same<_Iter, typename _Container::pointer>::__value), (std::__are_same<_Iter, typename _Container::pointer>::__value),
_Container>::__type>& __i) _Container>::__type>& __i) _GLIBCXX_NOEXCEPT
: _M_current(__i.base()) { } : _M_current(__i.base()) { }
#if __cplusplus >= 201103L #if __cplusplus >= 201103L
__normal_iterator<typename _Container::pointer, _Container> __normal_iterator<typename _Container::pointer, _Container>
_M_const_cast() const _M_const_cast() const noexcept
{ {
using _PTraits = std::pointer_traits<typename _Container::pointer>; using _PTraits = std::pointer_traits<typename _Container::pointer>;
return __normal_iterator<typename _Container::pointer, _Container> return __normal_iterator<typename _Container::pointer, _Container>
...@@ -751,59 +753,59 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -751,59 +753,59 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
// Forward iterator requirements // Forward iterator requirements
reference reference
operator*() const operator*() const _GLIBCXX_NOEXCEPT
{ return *_M_current; } { return *_M_current; }
pointer pointer
operator->() const operator->() const _GLIBCXX_NOEXCEPT
{ return _M_current; } { return _M_current; }
__normal_iterator& __normal_iterator&
operator++() operator++() _GLIBCXX_NOEXCEPT
{ {
++_M_current; ++_M_current;
return *this; return *this;
} }
__normal_iterator __normal_iterator
operator++(int) operator++(int) _GLIBCXX_NOEXCEPT
{ return __normal_iterator(_M_current++); } { return __normal_iterator(_M_current++); }
// Bidirectional iterator requirements // Bidirectional iterator requirements
__normal_iterator& __normal_iterator&
operator--() operator--() _GLIBCXX_NOEXCEPT
{ {
--_M_current; --_M_current;
return *this; return *this;
} }
__normal_iterator __normal_iterator
operator--(int) operator--(int) _GLIBCXX_NOEXCEPT
{ return __normal_iterator(_M_current--); } { return __normal_iterator(_M_current--); }
// Random access iterator requirements // Random access iterator requirements
reference reference
operator[](difference_type __n) const operator[](difference_type __n) const _GLIBCXX_NOEXCEPT
{ return _M_current[__n]; } { return _M_current[__n]; }
__normal_iterator& __normal_iterator&
operator+=(difference_type __n) operator+=(difference_type __n) _GLIBCXX_NOEXCEPT
{ _M_current += __n; return *this; } { _M_current += __n; return *this; }
__normal_iterator __normal_iterator
operator+(difference_type __n) const operator+(difference_type __n) const _GLIBCXX_NOEXCEPT
{ return __normal_iterator(_M_current + __n); } { return __normal_iterator(_M_current + __n); }
__normal_iterator& __normal_iterator&
operator-=(difference_type __n) operator-=(difference_type __n) _GLIBCXX_NOEXCEPT
{ _M_current -= __n; return *this; } { _M_current -= __n; return *this; }
__normal_iterator __normal_iterator
operator-(difference_type __n) const operator-(difference_type __n) const _GLIBCXX_NOEXCEPT
{ return __normal_iterator(_M_current - __n); } { return __normal_iterator(_M_current - __n); }
const _Iterator& const _Iterator&
base() const base() const _GLIBCXX_NOEXCEPT
{ return _M_current; } { return _M_current; }
}; };
...@@ -820,24 +822,28 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -820,24 +822,28 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
inline bool inline bool
operator==(const __normal_iterator<_IteratorL, _Container>& __lhs, operator==(const __normal_iterator<_IteratorL, _Container>& __lhs,
const __normal_iterator<_IteratorR, _Container>& __rhs) const __normal_iterator<_IteratorR, _Container>& __rhs)
_GLIBCXX_NOEXCEPT
{ return __lhs.base() == __rhs.base(); } { return __lhs.base() == __rhs.base(); }
template<typename _Iterator, typename _Container> template<typename _Iterator, typename _Container>
inline bool inline bool
operator==(const __normal_iterator<_Iterator, _Container>& __lhs, operator==(const __normal_iterator<_Iterator, _Container>& __lhs,
const __normal_iterator<_Iterator, _Container>& __rhs) const __normal_iterator<_Iterator, _Container>& __rhs)
_GLIBCXX_NOEXCEPT
{ return __lhs.base() == __rhs.base(); } { return __lhs.base() == __rhs.base(); }
template<typename _IteratorL, typename _IteratorR, typename _Container> template<typename _IteratorL, typename _IteratorR, typename _Container>
inline bool inline bool
operator!=(const __normal_iterator<_IteratorL, _Container>& __lhs, operator!=(const __normal_iterator<_IteratorL, _Container>& __lhs,
const __normal_iterator<_IteratorR, _Container>& __rhs) const __normal_iterator<_IteratorR, _Container>& __rhs)
_GLIBCXX_NOEXCEPT
{ return __lhs.base() != __rhs.base(); } { return __lhs.base() != __rhs.base(); }
template<typename _Iterator, typename _Container> template<typename _Iterator, typename _Container>
inline bool inline bool
operator!=(const __normal_iterator<_Iterator, _Container>& __lhs, operator!=(const __normal_iterator<_Iterator, _Container>& __lhs,
const __normal_iterator<_Iterator, _Container>& __rhs) const __normal_iterator<_Iterator, _Container>& __rhs)
_GLIBCXX_NOEXCEPT
{ return __lhs.base() != __rhs.base(); } { return __lhs.base() != __rhs.base(); }
// Random access iterator requirements // Random access iterator requirements
...@@ -845,48 +851,56 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -845,48 +851,56 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
inline bool inline bool
operator<(const __normal_iterator<_IteratorL, _Container>& __lhs, operator<(const __normal_iterator<_IteratorL, _Container>& __lhs,
const __normal_iterator<_IteratorR, _Container>& __rhs) const __normal_iterator<_IteratorR, _Container>& __rhs)
_GLIBCXX_NOEXCEPT
{ return __lhs.base() < __rhs.base(); } { return __lhs.base() < __rhs.base(); }
template<typename _Iterator, typename _Container> template<typename _Iterator, typename _Container>
inline bool inline bool
operator<(const __normal_iterator<_Iterator, _Container>& __lhs, operator<(const __normal_iterator<_Iterator, _Container>& __lhs,
const __normal_iterator<_Iterator, _Container>& __rhs) const __normal_iterator<_Iterator, _Container>& __rhs)
_GLIBCXX_NOEXCEPT
{ return __lhs.base() < __rhs.base(); } { return __lhs.base() < __rhs.base(); }
template<typename _IteratorL, typename _IteratorR, typename _Container> template<typename _IteratorL, typename _IteratorR, typename _Container>
inline bool inline bool
operator>(const __normal_iterator<_IteratorL, _Container>& __lhs, operator>(const __normal_iterator<_IteratorL, _Container>& __lhs,
const __normal_iterator<_IteratorR, _Container>& __rhs) const __normal_iterator<_IteratorR, _Container>& __rhs)
_GLIBCXX_NOEXCEPT
{ return __lhs.base() > __rhs.base(); } { return __lhs.base() > __rhs.base(); }
template<typename _Iterator, typename _Container> template<typename _Iterator, typename _Container>
inline bool inline bool
operator>(const __normal_iterator<_Iterator, _Container>& __lhs, operator>(const __normal_iterator<_Iterator, _Container>& __lhs,
const __normal_iterator<_Iterator, _Container>& __rhs) const __normal_iterator<_Iterator, _Container>& __rhs)
_GLIBCXX_NOEXCEPT
{ return __lhs.base() > __rhs.base(); } { return __lhs.base() > __rhs.base(); }
template<typename _IteratorL, typename _IteratorR, typename _Container> template<typename _IteratorL, typename _IteratorR, typename _Container>
inline bool inline bool
operator<=(const __normal_iterator<_IteratorL, _Container>& __lhs, operator<=(const __normal_iterator<_IteratorL, _Container>& __lhs,
const __normal_iterator<_IteratorR, _Container>& __rhs) const __normal_iterator<_IteratorR, _Container>& __rhs)
_GLIBCXX_NOEXCEPT
{ return __lhs.base() <= __rhs.base(); } { return __lhs.base() <= __rhs.base(); }
template<typename _Iterator, typename _Container> template<typename _Iterator, typename _Container>
inline bool inline bool
operator<=(const __normal_iterator<_Iterator, _Container>& __lhs, operator<=(const __normal_iterator<_Iterator, _Container>& __lhs,
const __normal_iterator<_Iterator, _Container>& __rhs) const __normal_iterator<_Iterator, _Container>& __rhs)
_GLIBCXX_NOEXCEPT
{ return __lhs.base() <= __rhs.base(); } { return __lhs.base() <= __rhs.base(); }
template<typename _IteratorL, typename _IteratorR, typename _Container> template<typename _IteratorL, typename _IteratorR, typename _Container>
inline bool inline bool
operator>=(const __normal_iterator<_IteratorL, _Container>& __lhs, operator>=(const __normal_iterator<_IteratorL, _Container>& __lhs,
const __normal_iterator<_IteratorR, _Container>& __rhs) const __normal_iterator<_IteratorR, _Container>& __rhs)
_GLIBCXX_NOEXCEPT
{ return __lhs.base() >= __rhs.base(); } { return __lhs.base() >= __rhs.base(); }
template<typename _Iterator, typename _Container> template<typename _Iterator, typename _Container>
inline bool inline bool
operator>=(const __normal_iterator<_Iterator, _Container>& __lhs, operator>=(const __normal_iterator<_Iterator, _Container>& __lhs,
const __normal_iterator<_Iterator, _Container>& __rhs) const __normal_iterator<_Iterator, _Container>& __rhs)
_GLIBCXX_NOEXCEPT
{ return __lhs.base() >= __rhs.base(); } { return __lhs.base() >= __rhs.base(); }
// _GLIBCXX_RESOLVE_LIB_DEFECTS // _GLIBCXX_RESOLVE_LIB_DEFECTS
...@@ -898,7 +912,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -898,7 +912,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
// DR 685. // DR 685.
inline auto inline auto
operator-(const __normal_iterator<_IteratorL, _Container>& __lhs, operator-(const __normal_iterator<_IteratorL, _Container>& __lhs,
const __normal_iterator<_IteratorR, _Container>& __rhs) const __normal_iterator<_IteratorR, _Container>& __rhs) noexcept
-> decltype(__lhs.base() - __rhs.base()) -> decltype(__lhs.base() - __rhs.base())
#else #else
inline typename __normal_iterator<_IteratorL, _Container>::difference_type inline typename __normal_iterator<_IteratorL, _Container>::difference_type
...@@ -911,12 +925,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -911,12 +925,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
inline typename __normal_iterator<_Iterator, _Container>::difference_type inline typename __normal_iterator<_Iterator, _Container>::difference_type
operator-(const __normal_iterator<_Iterator, _Container>& __lhs, operator-(const __normal_iterator<_Iterator, _Container>& __lhs,
const __normal_iterator<_Iterator, _Container>& __rhs) const __normal_iterator<_Iterator, _Container>& __rhs)
_GLIBCXX_NOEXCEPT
{ return __lhs.base() - __rhs.base(); } { return __lhs.base() - __rhs.base(); }
template<typename _Iterator, typename _Container> template<typename _Iterator, typename _Container>
inline __normal_iterator<_Iterator, _Container> inline __normal_iterator<_Iterator, _Container>
operator+(typename __normal_iterator<_Iterator, _Container>::difference_type operator+(typename __normal_iterator<_Iterator, _Container>::difference_type
__n, const __normal_iterator<_Iterator, _Container>& __i) __n, const __normal_iterator<_Iterator, _Container>& __i)
_GLIBCXX_NOEXCEPT
{ return __normal_iterator<_Iterator, _Container>(__i.base() + __n); } { return __normal_iterator<_Iterator, _Container>(__i.base() + __n); }
_GLIBCXX_END_NAMESPACE_VERSION _GLIBCXX_END_NAMESPACE_VERSION
......
...@@ -1309,7 +1309,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER ...@@ -1309,7 +1309,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
*/ */
void void
#if __cplusplus >= 201103L #if __cplusplus >= 201103L
splice(const_iterator __position, list&& __x) splice(const_iterator __position, list&& __x) noexcept
#else #else
splice(iterator __position, list& __x) splice(iterator __position, list& __x)
#endif #endif
...@@ -1325,7 +1325,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER ...@@ -1325,7 +1325,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
#if __cplusplus >= 201103L #if __cplusplus >= 201103L
void void
splice(const_iterator __position, list& __x) splice(const_iterator __position, list& __x) noexcept
{ splice(__position, std::move(__x)); } { splice(__position, std::move(__x)); }
#endif #endif
...@@ -1341,7 +1341,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER ...@@ -1341,7 +1341,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
* inserts it into the current list before @a __position. * inserts it into the current list before @a __position.
*/ */
void void
splice(const_iterator __position, list&& __x, const_iterator __i) splice(const_iterator __position, list&& __x, const_iterator __i) noexcept
#else #else
/** /**
* @brief Insert element from another %list. * @brief Insert element from another %list.
...@@ -1380,7 +1380,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER ...@@ -1380,7 +1380,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
* inserts it into the current list before @a __position. * inserts it into the current list before @a __position.
*/ */
void void
splice(const_iterator __position, list& __x, const_iterator __i) splice(const_iterator __position, list& __x, const_iterator __i) noexcept
{ splice(__position, std::move(__x), __i); } { splice(__position, std::move(__x), __i); }
#endif #endif
...@@ -1400,7 +1400,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER ...@@ -1400,7 +1400,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
*/ */
void void
splice(const_iterator __position, list&& __x, const_iterator __first, splice(const_iterator __position, list&& __x, const_iterator __first,
const_iterator __last) const_iterator __last) noexcept
#else #else
/** /**
* @brief Insert range from another %list. * @brief Insert range from another %list.
...@@ -1446,7 +1446,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER ...@@ -1446,7 +1446,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
*/ */
void void
splice(const_iterator __position, list& __x, const_iterator __first, splice(const_iterator __position, list& __x, const_iterator __first,
const_iterator __last) const_iterator __last) noexcept
{ splice(__position, std::move(__x), __first, __last); } { splice(__position, std::move(__x), __first, __last); }
#endif #endif
...@@ -1696,11 +1696,11 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER ...@@ -1696,11 +1696,11 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
// To implement the splice (and merge) bits of N1599. // To implement the splice (and merge) bits of N1599.
void void
_M_check_equal_allocators(list& __x) _M_check_equal_allocators(list& __x) _GLIBCXX_NOEXCEPT
{ {
if (std::__alloc_neq<typename _Base::_Node_alloc_type>:: if (std::__alloc_neq<typename _Base::_Node_alloc_type>::
_S_do_it(_M_get_Node_allocator(), __x._M_get_Node_allocator())) _S_do_it(_M_get_Node_allocator(), __x._M_get_Node_allocator()))
__throw_runtime_error(__N("list::_M_check_equal_allocators")); __builtin_abort();
} }
}; };
......
...@@ -147,7 +147,7 @@ namespace __debug ...@@ -147,7 +147,7 @@ namespace __debug
// Element access. // Element access.
reference reference
operator[](size_type __n) operator[](size_type __n) noexcept
{ {
__glibcxx_check_subscript(__n); __glibcxx_check_subscript(__n);
return _AT_Type::_S_ref(_M_elems, __n); return _AT_Type::_S_ref(_M_elems, __n);
...@@ -180,14 +180,14 @@ namespace __debug ...@@ -180,14 +180,14 @@ namespace __debug
} }
reference reference
front() front() noexcept
{ {
__glibcxx_check_nonempty(); __glibcxx_check_nonempty();
return *begin(); return *begin();
} }
constexpr const_reference constexpr const_reference
front() const front() const noexcept
{ {
return _Nm ? _AT_Type::_S_ref(_M_elems, 0) return _Nm ? _AT_Type::_S_ref(_M_elems, 0)
: (_GLIBCXX_THROW_OR_ABORT(_Array_check_nonempty<_Nm>()), : (_GLIBCXX_THROW_OR_ABORT(_Array_check_nonempty<_Nm>()),
...@@ -195,14 +195,14 @@ namespace __debug ...@@ -195,14 +195,14 @@ namespace __debug
} }
reference reference
back() back() noexcept
{ {
__glibcxx_check_nonempty(); __glibcxx_check_nonempty();
return _Nm ? *(end() - 1) : *end(); return _Nm ? *(end() - 1) : *end();
} }
constexpr const_reference constexpr const_reference
back() const back() const noexcept
{ {
return _Nm ? _AT_Type::_S_ref(_M_elems, _Nm - 1) return _Nm ? _AT_Type::_S_ref(_M_elems, _Nm - 1)
: (_GLIBCXX_THROW_OR_ABORT(_Array_check_nonempty<_Nm>()), : (_GLIBCXX_THROW_OR_ABORT(_Array_check_nonempty<_Nm>()),
......
...@@ -515,7 +515,7 @@ namespace __debug ...@@ -515,7 +515,7 @@ namespace __debug
// 23.2.2.4 list operations: // 23.2.2.4 list operations:
void void
#if __cplusplus >= 201103L #if __cplusplus >= 201103L
splice(const_iterator __position, list&& __x) splice(const_iterator __position, list&& __x) noexcept
#else #else
splice(iterator __position, list& __x) splice(iterator __position, list& __x)
#endif #endif
...@@ -529,13 +529,13 @@ namespace __debug ...@@ -529,13 +529,13 @@ namespace __debug
#if __cplusplus >= 201103L #if __cplusplus >= 201103L
void void
splice(const_iterator __position, list& __x) splice(const_iterator __position, list& __x) noexcept
{ splice(__position, std::move(__x)); } { splice(__position, std::move(__x)); }
#endif #endif
void void
#if __cplusplus >= 201103L #if __cplusplus >= 201103L
splice(const_iterator __position, list&& __x, const_iterator __i) splice(const_iterator __position, list&& __x, const_iterator __i) noexcept
#else #else
splice(iterator __position, list& __x, iterator __i) splice(iterator __position, list& __x, iterator __i)
#endif #endif
...@@ -561,14 +561,14 @@ namespace __debug ...@@ -561,14 +561,14 @@ namespace __debug
#if __cplusplus >= 201103L #if __cplusplus >= 201103L
void void
splice(const_iterator __position, list& __x, const_iterator __i) splice(const_iterator __position, list& __x, const_iterator __i) noexcept
{ splice(__position, std::move(__x), __i); } { splice(__position, std::move(__x), __i); }
#endif #endif
void void
#if __cplusplus >= 201103L #if __cplusplus >= 201103L
splice(const_iterator __position, list&& __x, const_iterator __first, splice(const_iterator __position, list&& __x, const_iterator __first,
const_iterator __last) const_iterator __last) noexcept
#else #else
splice(iterator __position, list& __x, iterator __first, splice(iterator __position, list& __x, iterator __first,
iterator __last) iterator __last)
...@@ -608,7 +608,7 @@ namespace __debug ...@@ -608,7 +608,7 @@ namespace __debug
#if __cplusplus >= 201103L #if __cplusplus >= 201103L
void void
splice(const_iterator __position, list& __x, splice(const_iterator __position, list& __x,
const_iterator __first, const_iterator __last) const_iterator __first, const_iterator __last) noexcept
{ splice(__position, std::move(__x), __first, __last); } { splice(__position, std::move(__x), __first, __last); }
#endif #endif
......
...@@ -127,7 +127,7 @@ namespace __profile ...@@ -127,7 +127,7 @@ namespace __profile
// Element access. // Element access.
reference reference
operator[](size_type __n) operator[](size_type __n) noexcept
{ return _AT_Type::_S_ref(_M_elems, __n); } { return _AT_Type::_S_ref(_M_elems, __n); }
constexpr const_reference constexpr const_reference
...@@ -153,19 +153,19 @@ namespace __profile ...@@ -153,19 +153,19 @@ namespace __profile
} }
reference reference
front() front() noexcept
{ return *begin(); } { return *begin(); }
constexpr const_reference constexpr const_reference
front() const front() const noexcept
{ return _AT_Type::_S_ref(_M_elems, 0); } { return _AT_Type::_S_ref(_M_elems, 0); }
reference reference
back() back() noexcept
{ return _Nm ? *(end() - 1) : *end(); } { return _Nm ? *(end() - 1) : *end(); }
constexpr const_reference constexpr const_reference
back() const back() const noexcept
{ {
return _Nm ? _AT_Type::_S_ref(_M_elems, _Nm - 1) return _Nm ? _AT_Type::_S_ref(_M_elems, _Nm - 1)
: _AT_Type::_S_ref(_M_elems, 0); : _AT_Type::_S_ref(_M_elems, 0);
......
...@@ -440,7 +440,7 @@ template<typename _Tp, typename _Allocator = std::allocator<_Tp> > ...@@ -440,7 +440,7 @@ template<typename _Tp, typename _Allocator = std::allocator<_Tp> >
// 23.2.2.4 list operations: // 23.2.2.4 list operations:
void void
#if __cplusplus >= 201103L #if __cplusplus >= 201103L
splice(const_iterator __position, list&& __x) splice(const_iterator __position, list&& __x) noexcept
#else #else
splice(iterator __position, list& __x) splice(iterator __position, list& __x)
#endif #endif
...@@ -448,7 +448,7 @@ template<typename _Tp, typename _Allocator = std::allocator<_Tp> > ...@@ -448,7 +448,7 @@ template<typename _Tp, typename _Allocator = std::allocator<_Tp> >
#if __cplusplus >= 201103L #if __cplusplus >= 201103L
void void
splice(const_iterator __position, list& __x) splice(const_iterator __position, list& __x) noexcept
{ this->splice(__position, std::move(__x)); } { this->splice(__position, std::move(__x)); }
void void
...@@ -458,7 +458,7 @@ template<typename _Tp, typename _Allocator = std::allocator<_Tp> > ...@@ -458,7 +458,7 @@ template<typename _Tp, typename _Allocator = std::allocator<_Tp> >
void void
#if __cplusplus >= 201103L #if __cplusplus >= 201103L
splice(const_iterator __position, list&& __x, const_iterator __i) splice(const_iterator __position, list&& __x, const_iterator __i) noexcept
#else #else
splice(iterator __position, list& __x, iterator __i) splice(iterator __position, list& __x, iterator __i)
#endif #endif
...@@ -474,7 +474,7 @@ template<typename _Tp, typename _Allocator = std::allocator<_Tp> > ...@@ -474,7 +474,7 @@ template<typename _Tp, typename _Allocator = std::allocator<_Tp> >
void void
#if __cplusplus >= 201103L #if __cplusplus >= 201103L
splice(const_iterator __position, list&& __x, const_iterator __first, splice(const_iterator __position, list&& __x, const_iterator __first,
const_iterator __last) const_iterator __last) noexcept
#else #else
splice(iterator __position, list& __x, iterator __first, splice(iterator __position, list& __x, iterator __first,
iterator __last) iterator __last)
...@@ -490,7 +490,7 @@ template<typename _Tp, typename _Allocator = std::allocator<_Tp> > ...@@ -490,7 +490,7 @@ template<typename _Tp, typename _Allocator = std::allocator<_Tp> >
#if __cplusplus >= 201103L #if __cplusplus >= 201103L
void void
splice(const_iterator __position, list& __x, splice(const_iterator __position, list& __x,
const_iterator __first, const_iterator __last) const_iterator __first, const_iterator __last) noexcept
{ this->splice(__position, std::move(__x), __first, __last); } { this->splice(__position, std::move(__x), __first, __last); }
#endif #endif
......
...@@ -169,7 +169,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER ...@@ -169,7 +169,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
// Element access. // Element access.
reference reference
operator[](size_type __n) operator[](size_type __n) noexcept
{ return _AT_Type::_S_ref(_M_elems, __n); } { return _AT_Type::_S_ref(_M_elems, __n); }
constexpr const_reference constexpr const_reference
...@@ -195,19 +195,19 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER ...@@ -195,19 +195,19 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
} }
reference reference
front() front() noexcept
{ return *begin(); } { return *begin(); }
constexpr const_reference constexpr const_reference
front() const front() const noexcept
{ return _AT_Type::_S_ref(_M_elems, 0); } { return _AT_Type::_S_ref(_M_elems, 0); }
reference reference
back() back() noexcept
{ return _Nm ? *(end() - 1) : *end(); } { return _Nm ? *(end() - 1) : *end(); }
constexpr const_reference constexpr const_reference
back() const back() const noexcept
{ {
return _Nm ? _AT_Type::_S_ref(_M_elems, _Nm - 1) return _Nm ? _AT_Type::_S_ref(_M_elems, _Nm - 1)
: _AT_Type::_S_ref(_M_elems, 0); : _AT_Type::_S_ref(_M_elems, 0);
......
// 2006-01-19 Paolo Carlini <pcarlini@suse.de>
// Copyright (C) 2006-2013 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
#include "5.h"
#include <list>
int main()
{
typedef int value_type;
typedef __gnu_test::uneq_allocator<value_type> allocator_type;
typedef std::list<value_type, allocator_type> list_type;
operations05<list_type>();
return 0;
}
// 2006-01-19 Paolo Carlini <pcarlini@suse.de>
// Copyright (C) 2006-2013 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// 23.2.2.4 list operations [lib.list.ops]
#include <stdexcept>
#include <testsuite_hooks.h>
#include <testsuite_allocator.h>
// Check the splice (and merge) bits of N1599.
template<typename _Tp>
void
operations05()
{
bool test __attribute__((unused)) = true;
typedef _Tp list_type;
typedef typename list_type::allocator_type allocator_type;
const int data1[] = {1, 2, 3, 4, 5};
const int data2[] = {6, 7, 8, 9, 10};
const size_t N1 = sizeof(data1) / sizeof(int);
const size_t N2 = sizeof(data2) / sizeof(int);
allocator_type alloc01(1), alloc02(2);
list_type l01(data1, data1 + N1, alloc01);
const list_type l01_ref = l01;
list_type l02(data2, data2 + N2, alloc02);
const list_type l02_ref = l02;
bool catched = false;
try
{
l01.splice(l01.begin(), l02);
}
catch(std::runtime_error&)
{
catched = true;
}
catch(...)
{
VERIFY( false );
}
VERIFY( catched );
VERIFY( l01 == l01_ref );
VERIFY( l02 == l02_ref );
catched = false;
try
{
l01.splice(l01.begin(), l02, l02.begin());
}
catch(std::runtime_error&)
{
catched = true;
}
catch(...)
{
VERIFY( false );
}
VERIFY( catched );
VERIFY( l01 == l01_ref );
VERIFY( l02 == l02_ref );
catched = false;
try
{
l01.splice(l01.begin(), l02, l02.begin(), l02.end());
}
catch(std::runtime_error&)
{
catched = true;
}
catch(...)
{
VERIFY( false );
}
VERIFY( catched );
VERIFY( l01 == l01_ref );
VERIFY( l02 == l02_ref );
catched = false;
try
{
l01.merge(l02);
}
catch(std::runtime_error&)
{
catched = true;
}
catch(...)
{
VERIFY( false );
}
VERIFY( catched );
VERIFY( l01 == l01_ref );
VERIFY( l02 == l02_ref );
catched = false;
try
{
l01.merge(l02, std::less<int>());
}
catch(std::runtime_error&)
{
catched = true;
}
catch(...)
{
VERIFY( false );
}
VERIFY( catched );
VERIFY( l01 == l01_ref );
VERIFY( l02 == l02_ref );
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment