Commit 15ee1a77 by François Dumont

macros.h [...]: Add parameter to pass the 2 instances to check allocator equality.

2014-05-06  François Dumont  <fdumont@gcc.gnu.org>

	* include/debug/macros.h [__glibcxx_check_equal_allocs]: Add
	parameter to pass the 2 instances to check allocator equality.
	* include/debug/safe_container.h: New, define _Safe_container<>.
	* include/Makefile.am: Add previous.
	* include/debug/deque (std::__debug::deque<>): Inherit
	_Safe_container<>. Use default implementation for all special
	functions.
	* include/debug/forward_list (std::__debug::forward_list<>):
	Likewise.
	* include/debug/list (std::__debug::list<>): Likewise.
	* include/debug/map.h (std::__debug::map<>): Likewise.
	* include/debug/multimap.h (std::__debug::multimap<>): Likewise.
	* include/debug/set.h (std::__debug::set<>): Likewise.
	* include/debug/multiset.h (std::__debug::multiset<>): Likewise.
	* include/debug/string (std::__debug::basic_string<>): Likewise.
	* include/debug/unordered_map
	(std::__debug::unordered_map<>): Likewise.
	(std::__debug::unordered_multimap<>): Likewise.
	* include/debug/unordered_set
	(std::__debug::unordered_set<>): Likewise.
	(std::__debug::unordered_multiset<>): Likewise.
	* include/debug/vector (std::__debug::vector<>): Likewise.
	* include/debug/safe_base.h (_Safe_sequence_base()): Add
	noexcept.
	(_Safe_sequence_base(_Safe_sequence_base&&): Remove.
	(~_Safe_sequence_base()): Add noexcept.
	* include/debug/safe_sequence.h
	(std::__debug::_Safe_node_sequence<>): New.
	* include/debug/safe_unordered_base.h
	(_Safe_unordered_container_base()): Add noexcept.
	(~_Safe_unordered_container_base()): Likewise.
	(_M_swap(_Safe_unordered_container_base&)): Likewise.
	* include/debug/safe_unordered_container.h:
	(_Safe_unordered_container<>::_M_invalidate_locals()): New.
	(_Safe_unordered_container<>::_M_invalidate_all()): New.
	* src/c++11/debug.cc: Limit includes, adapt methods noexcept
	qualifications.
	* testsuite/util/debug/checks.h (check_construct1): Just implement
	an invalid constructor invocation  and no other operations
	potentially not supported by some types of container.
	(check_construct2): Likewise.
	(check_construct3): Likewise.
	* testsuite/23_containers/forward_list/allocator/move.cc: Add
	check on iterators to make sure they are correctly moved in debug
	mode.
	* testsuite/23_containers/forward_list/allocator/move_assign.cc:
	Likewise.
	* testsuite/23_containers/map/allocator/move.cc: Likewise.
	* testsuite/23_containers/map/allocator/move_assign.cc: Likewise.
	* testsuite/23_containers/multimap/allocator/move.cc: Likewise.
	* testsuite/23_containers/multimap/allocator/move_assign.cc:
	Likewise.
	* testsuite/23_containers/multiset/allocator/move.cc: Likewise.
	* testsuite/23_containers/multiset/allocator/move_assign.cc:
	Likewise.
	* testsuite/23_containers/set/allocator/move.cc: Likewise.
	* testsuite/23_containers/set/allocator/move_assign.cc: Likewise.
	* testsuite/23_containers/unordered_map/allocator/move.cc:
	Likewise.
	* testsuite/23_containers/unordered_map/allocator/move_assign.cc:
	Likewise.
	* testsuite/23_containers/unordered_multimap/allocator/move.cc:
	Likewise.
	* testsuite/23_containers/unordered_multimap/allocator/move_assign.cc:
	Likewise.
	* testsuite/23_containers/unordered_multiset/allocator/move.cc:
	Likewise.
	* testsuite/23_containers/unordered_multiset/allocator/move_assign.cc:
	Likewise.
	* testsuite/23_containers/unordered_set/allocator/move.cc:
	Likewise.
	* testsuite/23_containers/unordered_set/allocator/move_assign.cc:
	Likewise.
	* testsuite/23_containers/forward_list/debug/construct1_neg.cc:
	New.
	* testsuite/23_containers/forward_list/debug/construct2_neg.cc:
	New.
	* testsuite/23_containers/forward_list/debug/construct3_neg.cc:
	New.
	* testsuite/23_containers/forward_list/debug/construct4_neg.cc:
	New.
	* testsuite/23_containers/forward_list/debug/move_assign_neg.cc:
	New.
	* testsuite/23_containers/forward_list/debug/move_neg.cc: New.
	* testsuite/23_containers/map/debug/construct5_neg.cc: New.
	* testsuite/23_containers/map/debug/move_assign_neg.cc: New.
	* testsuite/23_containers/map/debug/move_neg.cc: New.
	* testsuite/23_containers/multimap/debug/construct5_neg.cc: New.
	* testsuite/23_containers/multimap/debug/move_assign_neg.cc: New.
	* testsuite/23_containers/multimap/debug/move_neg.cc: New.
	* testsuite/23_containers/multiset/debug/construct5_neg.cc: New.
	* testsuite/23_containers/multiset/debug/move_assign_neg.cc: New.
	* testsuite/23_containers/multiset/debug/move_neg.cc: New.
	* testsuite/23_containers/set/debug/construct5_neg.cc: New.
	* testsuite/23_containers/set/debug/move_assign_neg.cc: New.
	* testsuite/23_containers/set/debug/move_neg.cc: New.
	* testsuite/23_containers/unordered_map/debug/construct5_neg.cc:
	New.
	* testsuite/23_containers/unordered_map/debug/move_assign_neg.cc:
	New.
	* testsuite/23_containers/unordered_map/debug/move_neg.cc: New.
	* testsuite/23_containers/unordered_multimap/debug/construct5_neg.cc:
	New.
	* testsuite/23_containers/unordered_multimap/debug/move_assign_neg.cc:
	New.
	* testsuite/23_containers/unordered_multimap/debug/move_neg.cc:
	New.
	* testsuite/23_containers/unordered_multiset/debug/construct5_neg.cc:
	New.
	* testsuite/23_containers/unordered_multiset/debug/move_assign_neg.cc:
	New.
	* testsuite/23_containers/unordered_multiset/debug/move_neg.cc:
	New.
	* testsuite/23_containers/unordered_set/debug/construct5_neg.cc:
	New.
	* testsuite/23_containers/unordered_set/debug/move_assign_neg.cc:
	New.
	* testsuite/23_containers/unordered_set/debug/move_neg.cc: New.
	* testsuite/23_containers/vector/debug/move_neg.cc: New.

From-SVN: r210123
parent 6f7e0b57
2014-05-06 François Dumont <fdumont@gcc.gnu.org>
* include/debug/macros.h [__glibcxx_check_equal_allocs]: Add
parameter to pass the 2 instances to check allocator equality.
* include/debug/safe_container.h: New, define _Safe_container<>.
* include/Makefile.am: Add previous.
* include/debug/deque (std::__debug::deque<>): Inherit
_Safe_container<>. Use default implementation for all special
functions.
* include/debug/forward_list (std::__debug::forward_list<>):
Likewise.
* include/debug/list (std::__debug::list<>): Likewise.
* include/debug/map.h (std::__debug::map<>): Likewise.
* include/debug/multimap.h (std::__debug::multimap<>): Likewise.
* include/debug/set.h (std::__debug::set<>): Likewise.
* include/debug/multiset.h (std::__debug::multiset<>): Likewise.
* include/debug/string (std::__debug::basic_string<>): Likewise.
* include/debug/unordered_map
(std::__debug::unordered_map<>): Likewise.
(std::__debug::unordered_multimap<>): Likewise.
* include/debug/unordered_set
(std::__debug::unordered_set<>): Likewise.
(std::__debug::unordered_multiset<>): Likewise.
* include/debug/vector (std::__debug::vector<>): Likewise.
* include/debug/safe_base.h (_Safe_sequence_base()): Add
noexcept.
(_Safe_sequence_base(_Safe_sequence_base&&): Remove.
(~_Safe_sequence_base()): Add noexcept.
* include/debug/safe_sequence.h
(std::__debug::_Safe_node_sequence<>): New.
* include/debug/safe_unordered_base.h
(_Safe_unordered_container_base()): Add noexcept.
(~_Safe_unordered_container_base()): Likewise.
(_M_swap(_Safe_unordered_container_base&)): Likewise.
* include/debug/safe_unordered_container.h:
(_Safe_unordered_container<>::_M_invalidate_locals()): New.
(_Safe_unordered_container<>::_M_invalidate_all()): New.
* src/c++11/debug.cc: Limit includes, adapt methods noexcept
qualifications.
* testsuite/util/debug/checks.h (check_construct1): Just implement
an invalid constructor invocation and no other operations
potentially not supported by some types of container.
(check_construct2): Likewise.
(check_construct3): Likewise.
* testsuite/23_containers/forward_list/allocator/move.cc: Add
check on iterators to make sure they are correctly moved in debug
mode.
* testsuite/23_containers/forward_list/allocator/move_assign.cc:
Likewise.
* testsuite/23_containers/map/allocator/move.cc: Likewise.
* testsuite/23_containers/map/allocator/move_assign.cc: Likewise.
* testsuite/23_containers/multimap/allocator/move.cc: Likewise.
* testsuite/23_containers/multimap/allocator/move_assign.cc:
Likewise.
* testsuite/23_containers/multiset/allocator/move.cc: Likewise.
* testsuite/23_containers/multiset/allocator/move_assign.cc:
Likewise.
* testsuite/23_containers/set/allocator/move.cc: Likewise.
* testsuite/23_containers/set/allocator/move_assign.cc: Likewise.
* testsuite/23_containers/unordered_map/allocator/move.cc:
Likewise.
* testsuite/23_containers/unordered_map/allocator/move_assign.cc:
Likewise.
* testsuite/23_containers/unordered_multimap/allocator/move.cc:
Likewise.
* testsuite/23_containers/unordered_multimap/allocator/move_assign.cc:
Likewise.
* testsuite/23_containers/unordered_multiset/allocator/move.cc:
Likewise.
* testsuite/23_containers/unordered_multiset/allocator/move_assign.cc:
Likewise.
* testsuite/23_containers/unordered_set/allocator/move.cc:
Likewise.
* testsuite/23_containers/unordered_set/allocator/move_assign.cc:
Likewise.
* testsuite/23_containers/forward_list/debug/construct1_neg.cc:
New.
* testsuite/23_containers/forward_list/debug/construct2_neg.cc:
New.
* testsuite/23_containers/forward_list/debug/construct3_neg.cc:
New.
* testsuite/23_containers/forward_list/debug/construct4_neg.cc:
New.
* testsuite/23_containers/forward_list/debug/move_assign_neg.cc:
New.
* testsuite/23_containers/forward_list/debug/move_neg.cc: New.
* testsuite/23_containers/map/debug/construct5_neg.cc: New.
* testsuite/23_containers/map/debug/move_assign_neg.cc: New.
* testsuite/23_containers/map/debug/move_neg.cc: New.
* testsuite/23_containers/multimap/debug/construct5_neg.cc: New.
* testsuite/23_containers/multimap/debug/move_assign_neg.cc: New.
* testsuite/23_containers/multimap/debug/move_neg.cc: New.
* testsuite/23_containers/multiset/debug/construct5_neg.cc: New.
* testsuite/23_containers/multiset/debug/move_assign_neg.cc: New.
* testsuite/23_containers/multiset/debug/move_neg.cc: New.
* testsuite/23_containers/set/debug/construct5_neg.cc: New.
* testsuite/23_containers/set/debug/move_assign_neg.cc: New.
* testsuite/23_containers/set/debug/move_neg.cc: New.
* testsuite/23_containers/unordered_map/debug/construct5_neg.cc:
New.
* testsuite/23_containers/unordered_map/debug/move_assign_neg.cc:
New.
* testsuite/23_containers/unordered_map/debug/move_neg.cc: New.
* testsuite/23_containers/unordered_multimap/debug/construct5_neg.cc:
New.
* testsuite/23_containers/unordered_multimap/debug/move_assign_neg.cc:
New.
* testsuite/23_containers/unordered_multimap/debug/move_neg.cc:
New.
* testsuite/23_containers/unordered_multiset/debug/construct5_neg.cc:
New.
* testsuite/23_containers/unordered_multiset/debug/move_assign_neg.cc:
New.
* testsuite/23_containers/unordered_multiset/debug/move_neg.cc:
New.
* testsuite/23_containers/unordered_set/debug/construct5_neg.cc:
New.
* testsuite/23_containers/unordered_set/debug/move_assign_neg.cc:
New.
* testsuite/23_containers/unordered_set/debug/move_neg.cc: New.
* testsuite/23_containers/vector/debug/move_neg.cc: New.
2014-05-05 Andreas Schwab <schwab@linux-m68k.org>
* config/abi/post/ia64-linux-gnu/baseline_symbols.txt
......
......@@ -733,6 +733,7 @@ debug_headers = \
${debug_srcdir}/multimap.h \
${debug_srcdir}/multiset.h \
${debug_srcdir}/safe_base.h \
${debug_srcdir}/safe_container.h \
${debug_srcdir}/safe_iterator.h \
${debug_srcdir}/safe_iterator.tcc \
${debug_srcdir}/safe_local_iterator.h \
......
......@@ -31,6 +31,7 @@
#include <deque>
#include <debug/safe_sequence.h>
#include <debug/safe_container.h>
#include <debug/safe_iterator.h>
namespace std _GLIBCXX_VISIBILITY(default)
......@@ -40,21 +41,26 @@ namespace __debug
/// Class std::deque with safety/checking/debug instrumentation.
template<typename _Tp, typename _Allocator = std::allocator<_Tp> >
class deque
: public _GLIBCXX_STD_C::deque<_Tp, _Allocator>,
public __gnu_debug::_Safe_sequence<deque<_Tp, _Allocator> >
: public __gnu_debug::_Safe_container<
deque<_Tp, _Allocator>, _Allocator,
__gnu_debug::_Safe_sequence, false>,
public _GLIBCXX_STD_C::deque<_Tp, _Allocator>
{
typedef _GLIBCXX_STD_C::deque<_Tp, _Allocator> _Base;
typedef __gnu_debug::_Safe_container<
deque, _Allocator, __gnu_debug::_Safe_sequence, false> _Safe;
typedef typename _Base::const_iterator _Base_const_iterator;
typedef typename _Base::iterator _Base_iterator;
typedef __gnu_debug::_Equal_to<_Base_const_iterator> _Equal;
public:
typedef typename _Base::reference reference;
typedef typename _Base::const_reference const_reference;
typedef __gnu_debug::_Safe_iterator<_Base_iterator,deque>
typedef __gnu_debug::_Safe_iterator<_Base_iterator, deque>
iterator;
typedef __gnu_debug::_Safe_iterator<_Base_const_iterator,deque>
typedef __gnu_debug::_Safe_iterator<_Base_const_iterator, deque>
const_iterator;
typedef typename _Base::size_type size_type;
......@@ -69,7 +75,25 @@ namespace __debug
// 23.2.1.1 construct/copy/destroy:
deque() : _Base() { }
#if __cplusplus < 201103L
deque()
: _Base() { }
deque(const deque& __x)
: _Base(__x) { }
~deque() { }
#else
deque() = default;
deque(const deque&) = default;
deque(deque&&) = default;
deque(initializer_list<value_type> __l,
const allocator_type& __a = allocator_type())
: _Base(__l, __a) { }
~deque() = default;
#endif
explicit
deque(const _Allocator& __a)
......@@ -103,48 +127,28 @@ namespace __debug
__gnu_debug::__base(__last), __a)
{ }
deque(const deque& __x)
: _Base(__x) { }
deque(const _Base& __x)
: _Base(__x) { }
#if __cplusplus >= 201103L
deque(deque&& __x)
: _Base(std::move(__x))
{ this->_M_swap(__x); }
deque(initializer_list<value_type> __l,
const allocator_type& __a = allocator_type())
: _Base(__l, __a) { }
#endif
~deque() _GLIBCXX_NOEXCEPT { }
#if __cplusplus < 201103L
deque&
operator=(const deque& __x)
{
*static_cast<_Base*>(this) = __x;
this->_M_invalidate_all();
this->_M_safe() = __x;
_M_base() = __x;
return *this;
}
#else
deque&
operator=(const deque&) = default;
#if __cplusplus >= 201103L
deque&
operator=(deque&& __x) noexcept
{
// NB: DR 1204.
// NB: DR 675.
__glibcxx_check_self_move_assign(__x);
clear();
swap(__x);
return *this;
}
operator=(deque&&) = default;
deque&
operator=(initializer_list<value_type> __l)
{
*static_cast<_Base*>(this) = __l;
_M_base() = __l;
this->_M_invalidate_all();
return *this;
}
......@@ -559,10 +563,13 @@ namespace __debug
}
void
swap(deque& __x) _GLIBCXX_NOEXCEPT
swap(deque& __x)
#if __cplusplus >= 201103L
noexcept( noexcept(declval<_Base>().swap(__x)) )
#endif
{
_Safe::_M_swap(__x);
_Base::swap(__x);
this->_M_swap(__x);
}
void
......
......@@ -31,6 +31,7 @@
#include <list>
#include <debug/safe_sequence.h>
#include <debug/safe_container.h>
#include <debug/safe_iterator.h>
namespace std _GLIBCXX_VISIBILITY(default)
......@@ -40,15 +41,20 @@ namespace __debug
/// Class std::list with safety/checking/debug instrumentation.
template<typename _Tp, typename _Allocator = std::allocator<_Tp> >
class list
: public _GLIBCXX_STD_C::list<_Tp, _Allocator>,
public __gnu_debug::_Safe_sequence<list<_Tp, _Allocator> >
: public __gnu_debug::_Safe_container<
list<_Tp, _Allocator>, _Allocator,
__gnu_debug::_Safe_node_sequence, false>,
public _GLIBCXX_STD_C::list<_Tp, _Allocator>
{
typedef _GLIBCXX_STD_C::list<_Tp, _Allocator> _Base;
typedef __gnu_debug::_Safe_container<
list, _Allocator, __gnu_debug::_Safe_node_sequence, false> _Safe;
typedef typename _Base::iterator _Base_iterator;
typedef typename _Base::const_iterator _Base_const_iterator;
typedef __gnu_debug::_Equal_to<_Base_const_iterator> _Equal;
typedef __gnu_debug::_Not_equal_to<_Base_const_iterator> _Not_equal;
public:
typedef typename _Base::reference reference;
typedef typename _Base::const_reference const_reference;
......@@ -70,9 +76,26 @@ namespace __debug
// 23.2.2.1 construct/copy/destroy:
list() _GLIBCXX_NOEXCEPT
#if __cplusplus < 201103L
list()
: _Base() { }
list(const list& __x)
: _Base(__x) { }
~list() { }
#else
list() = default;
list(const list&) = default;
list(list&&) = default;
list(initializer_list<value_type> __l,
const allocator_type& __a = allocator_type())
: _Base(__l, __a) { }
~list() = default;
#endif
explicit
list(const _Allocator& __a) _GLIBCXX_NOEXCEPT
: _Base(__a) { }
......@@ -105,49 +128,29 @@ namespace __debug
__gnu_debug::__base(__last), __a)
{ }
list(const list& __x)
: _Base(__x) { }
list(const _Base& __x)
: _Base(__x) { }
#if __cplusplus >= 201103L
list(list&& __x) noexcept
: _Base(std::move(__x))
{ this->_M_swap(__x); }
list(initializer_list<value_type> __l,
const allocator_type& __a = allocator_type())
: _Base(__l, __a) { }
#endif
~list() _GLIBCXX_NOEXCEPT { }
#if __cplusplus < 201103L
list&
operator=(const list& __x)
{
static_cast<_Base&>(*this) = __x;
this->_M_invalidate_all();
this->_M_safe() = __x;
_M_base() = __x;
return *this;
}
#else
list&
operator=(const list&) = default;
#if __cplusplus >= 201103L
list&
operator=(list&& __x)
{
// NB: DR 1204.
// NB: DR 675.
__glibcxx_check_self_move_assign(__x);
clear();
swap(__x);
return *this;
}
operator=(list&&) = default;
list&
operator=(initializer_list<value_type> __l)
{
static_cast<_Base&>(*this) = __l;
this->_M_invalidate_all();
_M_base() = __l;
return *this;
}
......@@ -245,16 +248,14 @@ namespace __debug
{
this->_M_detach_singular();
// if __sz < size(), invalidate all iterators in [begin+__sz, end())
// if __sz < size(), invalidate all iterators in [begin + __sz, end())
_Base_iterator __victim = _Base::begin();
_Base_iterator __end = _Base::end();
for (size_type __i = __sz; __victim != __end && __i > 0; --__i)
++__victim;
for (; __victim != __end; ++__victim)
{
this->_M_invalidate_if(_Equal(__victim));
}
__try
{
......@@ -272,16 +273,14 @@ namespace __debug
{
this->_M_detach_singular();
// if __sz < size(), invalidate all iterators in [begin+__sz, end())
// if __sz < size(), invalidate all iterators in [begin + __sz, end())
_Base_iterator __victim = _Base::begin();
_Base_iterator __end = _Base::end();
for (size_type __i = __sz; __victim != __end && __i > 0; --__i)
++__victim;
for (; __victim != __end; ++__victim)
{
this->_M_invalidate_if(_Equal(__victim));
}
__try
{
......@@ -299,16 +298,14 @@ namespace __debug
{
this->_M_detach_singular();
// if __sz < size(), invalidate all iterators in [begin+__sz, end())
// if __sz < size(), invalidate all iterators in [begin + __sz, end())
_Base_iterator __victim = _Base::begin();
_Base_iterator __end = _Base::end();
for (size_type __i = __sz; __victim != __end && __i > 0; --__i)
++__victim;
for (; __victim != __end; ++__victim)
{
this->_M_invalidate_if(_Equal(__victim));
}
__try
{
......@@ -504,9 +501,12 @@ namespace __debug
void
swap(list& __x)
#if __cplusplus >= 201103L
noexcept( noexcept(declval<_Base>().swap(__x)) )
#endif
{
_Safe::_M_swap(__x);
_Base::swap(__x);
this->_M_swap(__x);
}
void
......@@ -742,13 +742,6 @@ namespace __debug
const _Base&
_M_base() const _GLIBCXX_NOEXCEPT { return *this; }
private:
void
_M_invalidate_all()
{
this->_M_invalidate_if(_Not_equal(_Base::end()));
}
};
template<typename _Tp, typename _Alloc>
......
......@@ -347,10 +347,10 @@ _GLIBCXX_DEBUG_VERIFY(_F > 0.0f, \
_M_message(__gnu_debug::__msg_valid_load_factor) \
._M_sequence(*this, "this"))
#define __glibcxx_check_equal_allocs(_Other) \
_GLIBCXX_DEBUG_VERIFY(this->get_allocator() == _Other.get_allocator(), \
#define __glibcxx_check_equal_allocs(_This, _Other) \
_GLIBCXX_DEBUG_VERIFY(_This.get_allocator() == _Other.get_allocator(), \
_M_message(__gnu_debug::__msg_equal_allocs) \
._M_sequence(*this, "this"))
._M_sequence(_This, "this"))
#ifdef _GLIBCXX_DEBUG_PEDANTIC
# define __glibcxx_check_string(_String) _GLIBCXX_DEBUG_ASSERT(_String != 0)
......
......@@ -30,6 +30,7 @@
#define _GLIBCXX_DEBUG_MAP_H 1
#include <debug/safe_sequence.h>
#include <debug/safe_container.h>
#include <debug/safe_iterator.h>
#include <utility>
......@@ -41,19 +42,20 @@ namespace __debug
template<typename _Key, typename _Tp, typename _Compare = std::less<_Key>,
typename _Allocator = std::allocator<std::pair<const _Key, _Tp> > >
class map
: public _GLIBCXX_STD_C::map<_Key, _Tp, _Compare, _Allocator>,
public __gnu_debug::_Safe_sequence<map<_Key, _Tp, _Compare, _Allocator> >
: public __gnu_debug::_Safe_container<
map<_Key, _Tp, _Compare, _Allocator>, _Allocator,
__gnu_debug::_Safe_node_sequence>,
public _GLIBCXX_STD_C::map<_Key, _Tp, _Compare, _Allocator>
{
typedef _GLIBCXX_STD_C::map<_Key, _Tp, _Compare, _Allocator> _Base;
typedef _GLIBCXX_STD_C::map<
_Key, _Tp, _Compare, _Allocator> _Base;
typedef __gnu_debug::_Safe_container<
map, _Allocator, __gnu_debug::_Safe_node_sequence> _Safe;
typedef typename _Base::const_iterator _Base_const_iterator;
typedef typename _Base::iterator _Base_iterator;
typedef __gnu_debug::_Equal_to<_Base_const_iterator> _Equal;
#if __cplusplus >= 201103L
typedef __gnu_cxx::__alloc_traits<typename
_Base::allocator_type> _Alloc_traits;
#endif
public:
// types:
typedef _Key key_type;
......@@ -78,32 +80,17 @@ namespace __debug
// 23.3.1.1 construct/copy/destroy:
#if __cplusplus < 201103L
map() : _Base() { }
explicit map(const _Compare& __comp,
const _Allocator& __a = _Allocator())
: _Base(__comp, __a) { }
template<typename _InputIterator>
map(_InputIterator __first, _InputIterator __last,
const _Compare& __comp = _Compare(),
const _Allocator& __a = _Allocator())
: _Base(__gnu_debug::__base(__gnu_debug::__check_valid_range(__first,
__last)),
__gnu_debug::__base(__last),
__comp, __a) { }
map(const map& __x)
: _Base(__x) { }
map(const _Base& __x)
: _Base(__x) { }
#if __cplusplus >= 201103L
map(map&& __x)
noexcept(is_nothrow_copy_constructible<_Compare>::value)
: _Base(std::move(__x))
{ this->_M_swap(__x); }
~map() { }
#else
map() = default;
map(const map&) = default;
map(map&&) = default;
map(initializer_list<value_type> __l,
const _Compare& __c = _Compare(),
......@@ -118,7 +105,8 @@ namespace __debug
: _Base(__m, __a) { }
map(map&& __m, const allocator_type& __a)
: _Base(std::move(__m._M_base()), __a) { }
: _Safe(std::move(__m._M_safe()), __a),
_Base(std::move(__m._M_base()), __a) { }
map(initializer_list<value_type> __l, const allocator_type& __a)
: _Base(__l, __a) { }
......@@ -130,34 +118,40 @@ namespace __debug
__last)),
__gnu_debug::__base(__last), __a)
{ }
~map() = default;
#endif
~map() _GLIBCXX_NOEXCEPT { }
map(const _Base& __x)
: _Base(__x) { }
explicit map(const _Compare& __comp,
const _Allocator& __a = _Allocator())
: _Base(__comp, __a) { }
template<typename _InputIterator>
map(_InputIterator __first, _InputIterator __last,
const _Compare& __comp = _Compare(),
const _Allocator& __a = _Allocator())
: _Base(__gnu_debug::__base(__gnu_debug::__check_valid_range(__first,
__last)),
__gnu_debug::__base(__last),
__comp, __a) { }
#if __cplusplus < 201103L
map&
operator=(const map& __x)
{
this->_M_safe() = __x;
_M_base() = __x;
this->_M_invalidate_all();
return *this;
}
#else
map&
operator=(const map&) = default;
#if __cplusplus >= 201103L
map&
operator=(map&& __x)
noexcept(_Alloc_traits::_S_nothrow_move())
{
__glibcxx_check_self_move_assign(__x);
bool __xfer_memory = _Alloc_traits::_S_propagate_on_move_assign()
|| __x.get_allocator() == this->get_allocator();
_M_base() = std::move(__x._M_base());
if (__xfer_memory)
this->_M_swap(__x);
else
this->_M_invalidate_all();
__x._M_invalidate_all();
return *this;
}
operator=(map&&) = default;
map&
operator=(initializer_list<value_type> __l)
......@@ -395,15 +389,11 @@ namespace __debug
void
swap(map& __x)
#if __cplusplus >= 201103L
noexcept(_Alloc_traits::_S_nothrow_swap())
noexcept( noexcept(declval<_Base>().swap(__x)) )
#endif
{
#if __cplusplus >= 201103L
if (!_Alloc_traits::_S_propagate_on_swap())
__glibcxx_check_equal_allocs(__x);
#endif
_Safe::_M_swap(__x);
_Base::swap(__x);
this->_M_swap(__x);
}
void
......@@ -467,14 +457,6 @@ namespace __debug
const _Base&
_M_base() const _GLIBCXX_NOEXCEPT { return *this; }
private:
void
_M_invalidate_all()
{
typedef __gnu_debug::_Not_equal_to<_Base_const_iterator> _Not_equal;
this->_M_invalidate_if(_Not_equal(_M_base().end()));
}
};
template<typename _Key, typename _Tp,
......
......@@ -30,6 +30,7 @@
#define _GLIBCXX_DEBUG_MULTIMAP_H 1
#include <debug/safe_sequence.h>
#include <debug/safe_container.h>
#include <debug/safe_iterator.h>
#include <utility>
......@@ -41,20 +42,20 @@ namespace __debug
template<typename _Key, typename _Tp, typename _Compare = std::less<_Key>,
typename _Allocator = std::allocator<std::pair<const _Key, _Tp> > >
class multimap
: public _GLIBCXX_STD_C::multimap<_Key, _Tp, _Compare, _Allocator>,
public __gnu_debug::_Safe_sequence<multimap<_Key, _Tp,
_Compare, _Allocator> >
: public __gnu_debug::_Safe_container<
multimap<_Key, _Tp, _Compare, _Allocator>, _Allocator,
__gnu_debug::_Safe_node_sequence>,
public _GLIBCXX_STD_C::multimap<_Key, _Tp, _Compare, _Allocator>
{
typedef _GLIBCXX_STD_C::multimap<_Key, _Tp, _Compare, _Allocator> _Base;
typedef _GLIBCXX_STD_C::multimap<
_Key, _Tp, _Compare, _Allocator> _Base;
typedef __gnu_debug::_Safe_container<
multimap, _Allocator, __gnu_debug::_Safe_node_sequence> _Safe;
typedef typename _Base::const_iterator _Base_const_iterator;
typedef typename _Base::iterator _Base_iterator;
typedef __gnu_debug::_Equal_to<_Base_const_iterator> _Equal;
#if __cplusplus >= 201103L
typedef __gnu_cxx::__alloc_traits<typename
_Base::allocator_type> _Alloc_traits;
#endif
public:
// types:
typedef _Key key_type;
......@@ -79,32 +80,17 @@ namespace __debug
// 23.3.1.1 construct/copy/destroy:
#if __cplusplus < 201103L
multimap() : _Base() { }
explicit multimap(const _Compare& __comp,
const _Allocator& __a = _Allocator())
: _Base(__comp, __a) { }
template<typename _InputIterator>
multimap(_InputIterator __first, _InputIterator __last,
const _Compare& __comp = _Compare(),
const _Allocator& __a = _Allocator())
: _Base(__gnu_debug::__base(__gnu_debug::__check_valid_range(__first,
__last)),
__gnu_debug::__base(__last),
__comp, __a) { }
multimap(const multimap& __x)
: _Base(__x) { }
multimap(const _Base& __x)
: _Base(__x) { }
#if __cplusplus >= 201103L
multimap(multimap&& __x)
noexcept(is_nothrow_copy_constructible<_Compare>::value)
: _Base(std::move(__x))
{ this->_M_swap(__x); }
~multimap() { }
#else
multimap() = default;
multimap(const multimap&) = default;
multimap(multimap&&) = default;
multimap(initializer_list<value_type> __l,
const _Compare& __c = _Compare(),
......@@ -119,47 +105,52 @@ namespace __debug
: _Base(__m, __a) { }
multimap(multimap&& __m, const allocator_type& __a)
: _Base(std::move(__m._M_base()), __a) { }
: _Safe(std::move(__m._M_safe()), __a),
_Base(std::move(__m._M_base()), __a) { }
multimap(initializer_list<value_type> __l, const allocator_type& __a)
: _Base(__l, __a)
{ }
: _Base(__l, __a) { }
template<typename _InputIterator>
multimap(_InputIterator __first, _InputIterator __last,
const allocator_type& __a)
: _Base(__gnu_debug::__base(__gnu_debug::__check_valid_range(__first,
__last)),
__gnu_debug::__base(__last), __a)
{ }
__gnu_debug::__base(__last), __a) { }
~multimap() = default;
#endif
~multimap() _GLIBCXX_NOEXCEPT { }
explicit multimap(const _Compare& __comp,
const _Allocator& __a = _Allocator())
: _Base(__comp, __a) { }
template<typename _InputIterator>
multimap(_InputIterator __first, _InputIterator __last,
const _Compare& __comp = _Compare(),
const _Allocator& __a = _Allocator())
: _Base(__gnu_debug::__base(__gnu_debug::__check_valid_range(__first,
__last)),
__gnu_debug::__base(__last),
__comp, __a) { }
multimap(const _Base& __x)
: _Base(__x) { }
#if __cplusplus < 201103L
multimap&
operator=(const multimap& __x)
{
this->_M_safe() = __x;
_M_base() = __x;
this->_M_invalidate_all();
return *this;
}
#else
multimap&
operator=(const multimap&) = default;
#if __cplusplus >= 201103L
multimap&
operator=(multimap&& __x)
noexcept(_Alloc_traits::_S_nothrow_move())
{
__glibcxx_check_self_move_assign(__x);
bool __xfer_memory = _Alloc_traits::_S_propagate_on_move_assign()
|| __x.get_allocator() == this->get_allocator();
_M_base() = std::move(__x._M_base());
if (__xfer_memory)
this->_M_swap(__x);
else
this->_M_invalidate_all();
__x._M_invalidate_all();
return *this;
}
operator=(multimap&&) = default;
multimap&
operator=(initializer_list<value_type> __l)
......@@ -379,15 +370,11 @@ namespace __debug
void
swap(multimap& __x)
#if __cplusplus >= 201103L
noexcept(_Alloc_traits::_S_nothrow_swap())
noexcept( noexcept(declval<_Base>().swap(__x)) )
#endif
{
#if __cplusplus >= 201103L
if (!_Alloc_traits::_S_propagate_on_swap())
__glibcxx_check_equal_allocs(__x);
#endif
_Safe::_M_swap(__x);
_Base::swap(__x);
this->_M_swap(__x);
}
void
......@@ -451,14 +438,6 @@ namespace __debug
const _Base&
_M_base() const _GLIBCXX_NOEXCEPT { return *this; }
private:
void
_M_invalidate_all()
{
typedef __gnu_debug::_Not_equal_to<_Base_const_iterator> _Not_equal;
this->_M_invalidate_if(_Not_equal(_Base::end()));
}
};
template<typename _Key, typename _Tp,
......
......@@ -30,6 +30,7 @@
#define _GLIBCXX_DEBUG_MULTISET_H 1
#include <debug/safe_sequence.h>
#include <debug/safe_container.h>
#include <debug/safe_iterator.h>
#include <utility>
......@@ -41,19 +42,19 @@ namespace __debug
template<typename _Key, typename _Compare = std::less<_Key>,
typename _Allocator = std::allocator<_Key> >
class multiset
: public _GLIBCXX_STD_C::multiset<_Key, _Compare, _Allocator>,
public __gnu_debug::_Safe_sequence<multiset<_Key, _Compare, _Allocator> >
: public __gnu_debug::_Safe_container<
multiset<_Key, _Compare, _Allocator>, _Allocator,
__gnu_debug::_Safe_node_sequence>,
public _GLIBCXX_STD_C::multiset<_Key, _Compare, _Allocator>
{
typedef _GLIBCXX_STD_C::multiset<_Key, _Compare, _Allocator> _Base;
typedef __gnu_debug::_Safe_container<
multiset, _Allocator, __gnu_debug::_Safe_node_sequence> _Safe;
typedef typename _Base::const_iterator _Base_const_iterator;
typedef typename _Base::iterator _Base_iterator;
typedef __gnu_debug::_Equal_to<_Base_const_iterator> _Equal;
#if __cplusplus >= 201103L
typedef __gnu_cxx::__alloc_traits<typename
_Base::allocator_type> _Alloc_traits;
#endif
public:
// types:
typedef _Key key_type;
......@@ -78,32 +79,17 @@ namespace __debug
// 23.3.3.1 construct/copy/destroy:
#if __cplusplus < 201103L
multiset() : _Base() { }
explicit multiset(const _Compare& __comp,
const _Allocator& __a = _Allocator())
: _Base(__comp, __a) { }
template<typename _InputIterator>
multiset(_InputIterator __first, _InputIterator __last,
const _Compare& __comp = _Compare(),
const _Allocator& __a = _Allocator())
: _Base(__gnu_debug::__base(__gnu_debug::__check_valid_range(__first,
__last)),
__gnu_debug::__base(__last),
__comp, __a) { }
multiset(const multiset& __x)
: _Base(__x) { }
multiset(const _Base& __x)
: _Base(__x) { }
#if __cplusplus >= 201103L
multiset(multiset&& __x)
noexcept(is_nothrow_copy_constructible<_Compare>::value)
: _Base(std::move(__x))
{ this->_M_swap(__x); }
~multiset() { }
#else
multiset() = default;
multiset(const multiset&) = default;
multiset(multiset&&) = default;
multiset(initializer_list<value_type> __l,
const _Compare& __comp = _Compare(),
......@@ -118,7 +104,8 @@ namespace __debug
: _Base(__m, __a) { }
multiset(multiset&& __m, const allocator_type& __a)
: _Base(std::move(__m._M_base()), __a) { }
: _Safe(std::move(__m._M_safe()), __a),
_Base(std::move(__m._M_base()), __a) { }
multiset(initializer_list<value_type> __l, const allocator_type& __a)
: _Base(__l, __a)
......@@ -129,36 +116,41 @@ namespace __debug
const allocator_type& __a)
: _Base(__gnu_debug::__base(__gnu_debug::__check_valid_range(__first,
__last)),
__gnu_debug::__base(__last), __a)
{ }
__gnu_debug::__base(__last), __a) { }
~multiset() = default;
#endif
~multiset() _GLIBCXX_NOEXCEPT { }
explicit multiset(const _Compare& __comp,
const _Allocator& __a = _Allocator())
: _Base(__comp, __a) { }
template<typename _InputIterator>
multiset(_InputIterator __first, _InputIterator __last,
const _Compare& __comp = _Compare(),
const _Allocator& __a = _Allocator())
: _Base(__gnu_debug::__base(__gnu_debug::__check_valid_range(__first,
__last)),
__gnu_debug::__base(__last),
__comp, __a) { }
multiset(const _Base& __x)
: _Base(__x) { }
#if __cplusplus < 201103L
multiset&
operator=(const multiset& __x)
{
this->_M_safe() = __x;
_M_base() = __x;
this->_M_invalidate_all();
return *this;
}
#else
multiset&
operator=(const multiset&) = default;
#if __cplusplus >= 201103L
multiset&
operator=(multiset&& __x)
noexcept(_Alloc_traits::_S_nothrow_move())
{
__glibcxx_check_self_move_assign(__x);
bool __xfer_memory = _Alloc_traits::_S_propagate_on_move_assign()
|| __x.get_allocator() == this->get_allocator();
_M_base() = std::move(__x._M_base());
if (__xfer_memory)
this->_M_swap(__x);
else
this->_M_invalidate_all();
__x._M_invalidate_all();
return *this;
}
operator=(multiset&&) = default;
multiset&
operator=(initializer_list<value_type> __l)
......@@ -233,7 +225,8 @@ namespace __debug
iterator
emplace(_Args&&... __args)
{
return iterator(_Base::emplace(std::forward<_Args>(__args)...), this);
return iterator(_Base::emplace(std::forward<_Args>(__args)...),
this);
}
template<typename... _Args>
......@@ -364,15 +357,11 @@ namespace __debug
void
swap(multiset& __x)
#if __cplusplus >= 201103L
noexcept(_Alloc_traits::_S_nothrow_swap())
noexcept( noexcept(declval<_Base>().swap(__x)) )
#endif
{
#if __cplusplus >= 201103L
if (!_Alloc_traits::_S_propagate_on_swap())
__glibcxx_check_equal_allocs(__x);
#endif
_Safe::_M_swap(__x);
_Base::swap(__x);
this->_M_swap(__x);
}
void
......@@ -444,14 +433,6 @@ namespace __debug
const _Base&
_M_base() const _GLIBCXX_NOEXCEPT { return *this; }
private:
void
_M_invalidate_all()
{
typedef __gnu_debug::_Not_equal_to<_Base_const_iterator> _Not_equal;
this->_M_invalidate_if(_Not_equal(_Base::end()));
}
};
template<typename _Key, typename _Compare, typename _Allocator>
......
......@@ -104,7 +104,8 @@ namespace __gnu_debug
~_Safe_iterator_base() { this->_M_detach(); }
/** For use in _Safe_iterator. */
__gnu_cxx::__mutex& _M_get_mutex() throw ();
__gnu_cxx::__mutex&
_M_get_mutex() throw ();
public:
/** Attaches this iterator to the given sequence, detaching it
......@@ -112,30 +113,37 @@ namespace __gnu_debug
* new sequence is the NULL pointer, the iterator is left
* unattached.
*/
void _M_attach(_Safe_sequence_base* __seq, bool __constant);
void
_M_attach(_Safe_sequence_base* __seq, bool __constant);
/** Likewise, but not thread-safe. */
void _M_attach_single(_Safe_sequence_base* __seq, bool __constant) throw ();
void
_M_attach_single(_Safe_sequence_base* __seq, bool __constant) throw ();
/** Detach the iterator for whatever sequence it is attached to,
* if any.
*/
void _M_detach();
void
_M_detach();
/** Likewise, but not thread-safe. */
void _M_detach_single() throw ();
void
_M_detach_single() throw ();
/** Determines if we are attached to the given sequence. */
bool _M_attached_to(const _Safe_sequence_base* __seq) const
bool
_M_attached_to(const _Safe_sequence_base* __seq) const
{ return _M_sequence == __seq; }
/** Is this iterator singular? */
_GLIBCXX_PURE bool _M_singular() const throw ();
_GLIBCXX_PURE bool
_M_singular() const throw ();
/** Can we compare this iterator to the given iterator @p __x?
Returns true if both iterators are nonsingular and reference
the same sequence. */
_GLIBCXX_PURE bool _M_can_compare(const _Safe_iterator_base& __x) const throw ();
_GLIBCXX_PURE bool
_M_can_compare(const _Safe_iterator_base& __x) const throw ();
/** Invalidate the iterator, making it singular. */
void
......@@ -188,17 +196,13 @@ namespace __gnu_debug
protected:
// Initialize with a version number of 1 and no iterators
_Safe_sequence_base()
_Safe_sequence_base() _GLIBCXX_NOEXCEPT
: _M_iterators(0), _M_const_iterators(0), _M_version(1)
{ }
#if __cplusplus >= 201103L
_Safe_sequence_base(const _Safe_sequence_base&) noexcept
: _Safe_sequence_base() { }
_Safe_sequence_base(_Safe_sequence_base&& __x) noexcept
: _Safe_sequence_base()
{ _M_swap(__x); }
#endif
/** Notify all iterators that reference this sequence that the
......@@ -231,10 +235,11 @@ namespace __gnu_debug
* one container now reference the other container.
*/
void
_M_swap(_Safe_sequence_base& __x);
_M_swap(_Safe_sequence_base& __x) _GLIBCXX_USE_NOEXCEPT;
/** For use in _Safe_sequence. */
__gnu_cxx::__mutex& _M_get_mutex() throw ();
__gnu_cxx::__mutex&
_M_get_mutex() throw ();
public:
/** Invalidates all iterators. */
......
// Safe container implementation -*- C++ -*-
// Copyright (C) 2014 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.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file debug/safe_container.h
* This file is a GNU debug extension to the Standard C++ Library.
*/
#ifndef _GLIBCXX_DEBUG_SAFE_CONTAINER_H
#define _GLIBCXX_DEBUG_SAFE_CONTAINER_H 1
#include <ext/alloc_traits.h>
namespace __gnu_debug
{
/// Safe class dealing with some allocator dependent operations.
template<typename _SafeContainer,
typename _Alloc,
template<typename> class _SafeBase,
bool _IsCxx11AllocatorAware = true>
class _Safe_container
: public _SafeBase<_SafeContainer>
{
typedef _SafeBase<_SafeContainer> _Base;
_SafeContainer&
_M_cont() _GLIBCXX_NOEXCEPT
{ return *static_cast<_SafeContainer*>(this); }
protected:
_Safe_container&
_M_safe() _GLIBCXX_NOEXCEPT
{ return *this; }
#if __cplusplus >= 201103L
_Safe_container() = default;
_Safe_container(const _Safe_container&) = default;
_Safe_container(_Safe_container&& __x) noexcept
: _Safe_container()
{ _Base::_M_swap(__x); }
_Safe_container(_Safe_container&& __x,
const _Alloc& __a)
: _Safe_container()
{
if (__x._M_cont().get_allocator() == __a)
_Base::_M_swap(__x);
else
__x._M_invalidate_all();
}
#endif
public:
// Copy assignment invalidate all iterators.
_Safe_container&
operator=(const _Safe_container&) _GLIBCXX_NOEXCEPT
{
this->_M_invalidate_all();
return *this;
}
#if __cplusplus >= 201103L
_Safe_container&
operator=(_Safe_container&& __x) noexcept
{
__glibcxx_check_self_move_assign(__x);
if (_IsCxx11AllocatorAware)
{
typedef __gnu_cxx::__alloc_traits<_Alloc> _Alloc_traits;
bool __xfer_memory = _Alloc_traits::_S_propagate_on_move_assign()
|| _M_cont().get_allocator() == __x._M_cont().get_allocator();
if (__xfer_memory)
_Base::_M_swap(__x);
else
this->_M_invalidate_all();
}
else
_Base::_M_swap(__x);
__x._M_invalidate_all();
return *this;
}
void
_M_swap(_Safe_container& __x) noexcept
{
if (_IsCxx11AllocatorAware)
{
typedef __gnu_cxx::__alloc_traits<_Alloc> _Alloc_traits;
if (!_Alloc_traits::_S_propagate_on_swap())
__glibcxx_check_equal_allocs(this->_M_cont()._M_base(),
__x._M_cont()._M_base());
}
_Base::_M_swap(__x);
}
#endif
};
} // namespace __gnu_debug
#endif
......@@ -127,6 +127,25 @@ namespace __gnu_debug
void
_M_transfer_from_if(_Safe_sequence& __from, _Predicate __pred);
};
/// Like _Safe_sequence but with a special _M_invalidate_all implementation
/// not invalidating past-the-end iterators. Used by node based sequence.
template<typename _Sequence>
class _Safe_node_sequence
: public _Safe_sequence<_Sequence>
{
protected:
void
_M_invalidate_all()
{
typedef typename _Sequence::const_iterator _Const_iterator;
typedef typename _Const_iterator::iterator_type _Base_const_iterator;
typedef __gnu_debug::_Not_equal_to<_Base_const_iterator> _Not_equal;
const _Sequence& __seq = *static_cast<_Sequence*>(this);
this->_M_invalidate_if(_Not_equal(__seq._M_base().end()));
}
};
} // namespace __gnu_debug
#include <debug/safe_sequence.tcc>
......
......@@ -80,7 +80,7 @@ namespace __gnu_debug
~_Safe_local_iterator_base() { this->_M_detach(); }
_Safe_unordered_container_base*
_M_get_container() const _GLIBCXX_NOEXCEPT;
_M_get_container() const noexcept;
public:
/** Attaches this iterator to the given container, detaching it
......@@ -132,15 +132,16 @@ namespace __gnu_debug
protected:
// Initialize with a version number of 1 and no iterators
_Safe_unordered_container_base()
_Safe_unordered_container_base() noexcept
: _M_local_iterators(nullptr), _M_const_local_iterators(nullptr)
{ }
// Initialize with a version number of 1 and no iterators
// Copy constructor does not copy iterators.
_Safe_unordered_container_base(const _Safe_unordered_container_base&)
noexcept
: _Safe_unordered_container_base() { }
// When moved unordered containers iterators are swapped.
_Safe_unordered_container_base(_Safe_unordered_container_base&& __x)
noexcept
: _Safe_unordered_container_base()
......@@ -148,7 +149,7 @@ namespace __gnu_debug
/** Notify all iterators that reference this container that the
container is being destroyed. */
~_Safe_unordered_container_base()
~_Safe_unordered_container_base() noexcept
{ this->_M_detach_all(); }
/** Detach all iterators, leaving them singular. */
......@@ -161,7 +162,7 @@ namespace __gnu_debug
* one container now reference the other container.
*/
void
_M_swap(_Safe_unordered_container_base& __x);
_M_swap(_Safe_unordered_container_base& __x) noexcept;
public:
/** Attach an iterator to this container. */
......
......@@ -57,7 +57,31 @@ namespace __gnu_debug
template<typename _Container>
class _Safe_unordered_container : public _Safe_unordered_container_base
{
public:
private:
_Container&
_M_cont() noexcept
{ return *static_cast<_Container*>(this); }
protected:
void
_M_invalidate_locals()
{
auto __local_end = _M_cont()._M_base().end(0);
this->_M_invalidate_local_if(
[__local_end](__decltype(_M_cont()._M_base().cend(0)) __it)
{ return __it != __local_end; });
}
void
_M_invalidate_all()
{
auto __end = _M_cont()._M_base().end();
this->_M_invalidate_if(
[__end](__decltype(_M_cont()._M_base().cend()) __it)
{ return __it != __end; });
_M_invalidate_locals();
}
/** Invalidates all iterators @c x that reference this container,
are not singular, and for which @c __pred(x) returns @c
true. @c __pred will be invoked with the normal iterators nested
......
......@@ -30,6 +30,7 @@
#define _GLIBCXX_DEBUG_SET_H 1
#include <debug/safe_sequence.h>
#include <debug/safe_container.h>
#include <debug/safe_iterator.h>
#include <utility>
......@@ -41,18 +42,19 @@ namespace __debug
template<typename _Key, typename _Compare = std::less<_Key>,
typename _Allocator = std::allocator<_Key> >
class set
: public _GLIBCXX_STD_C::set<_Key,_Compare,_Allocator>,
public __gnu_debug::_Safe_sequence<set<_Key, _Compare, _Allocator> >
: public __gnu_debug::_Safe_container<
set<_Key, _Compare, _Allocator>, _Allocator,
__gnu_debug::_Safe_node_sequence>,
public _GLIBCXX_STD_C::set<_Key,_Compare,_Allocator>
{
typedef _GLIBCXX_STD_C::set<_Key, _Compare, _Allocator> _Base;
typedef __gnu_debug::_Safe_container<
set, _Allocator, __gnu_debug::_Safe_node_sequence> _Safe;
typedef typename _Base::const_iterator _Base_const_iterator;
typedef typename _Base::iterator _Base_iterator;
typedef __gnu_debug::_Equal_to<_Base_const_iterator> _Equal;
#if __cplusplus >= 201103L
typedef __gnu_cxx::__alloc_traits<typename
_Base::allocator_type> _Alloc_traits;
#endif
public:
// types:
typedef _Key key_type;
......@@ -77,32 +79,17 @@ namespace __debug
// 23.3.3.1 construct/copy/destroy:
#if __cplusplus < 201103L
set() : _Base() { }
explicit set(const _Compare& __comp,
const _Allocator& __a = _Allocator())
: _Base(__comp, __a) { }
template<typename _InputIterator>
set(_InputIterator __first, _InputIterator __last,
const _Compare& __comp = _Compare(),
const _Allocator& __a = _Allocator())
: _Base(__gnu_debug::__base(__gnu_debug::__check_valid_range(__first,
__last)),
__gnu_debug::__base(__last),
__comp, __a) { }
set(const set& __x)
: _Base(__x) { }
set(const _Base& __x)
: _Base(__x) { }
#if __cplusplus >= 201103L
set(set&& __x)
noexcept(is_nothrow_copy_constructible<_Compare>::value)
: _Base(std::move(__x))
{ this->_M_swap(__x); }
~set() { }
#else
set() = default;
set(const set&) = default;
set(set&&) = default;
set(initializer_list<value_type> __l,
const _Compare& __comp = _Compare(),
......@@ -117,47 +104,52 @@ namespace __debug
: _Base(__x, __a) { }
set(set&& __x, const allocator_type& __a)
: _Base(std::move(__x._M_base()), __a) { }
: _Safe(std::move(__x._M_safe()), __a),
_Base(std::move(__x._M_base()), __a) { }
set(initializer_list<value_type> __l, const allocator_type& __a)
: _Base(__l, __a)
{ }
: _Base(__l, __a) { }
template<typename _InputIterator>
set(_InputIterator __first, _InputIterator __last,
const allocator_type& __a)
: _Base(__gnu_debug::__base(__gnu_debug::__check_valid_range(__first,
__last)),
__gnu_debug::__base(__last), __a)
{ }
__gnu_debug::__base(__last), __a) { }
~set() = default;
#endif
~set() _GLIBCXX_NOEXCEPT { }
explicit set(const _Compare& __comp,
const _Allocator& __a = _Allocator())
: _Base(__comp, __a) { }
template<typename _InputIterator>
set(_InputIterator __first, _InputIterator __last,
const _Compare& __comp = _Compare(),
const _Allocator& __a = _Allocator())
: _Base(__gnu_debug::__base(__gnu_debug::__check_valid_range(__first,
__last)),
__gnu_debug::__base(__last),
__comp, __a) { }
set(const _Base& __x)
: _Base(__x) { }
#if __cplusplus < 201103L
set&
operator=(const set& __x)
{
this->_M_safe() = __x;
_M_base() = __x;
this->_M_invalidate_all();
return *this;
}
#else
set&
operator=(const set&) = default;
#if __cplusplus >= 201103L
set&
operator=(set&& __x)
noexcept(_Alloc_traits::_S_nothrow_move())
{
__glibcxx_check_self_move_assign(__x);
bool __xfer_memory = _Alloc_traits::_S_propagate_on_move_assign()
|| __x.get_allocator() == this->get_allocator();
_M_base() = std::move(__x._M_base());
if (__xfer_memory)
this->_M_swap(__x);
else
this->_M_invalidate_all();
__x._M_invalidate_all();
return *this;
}
operator=(set&&) = default;
set&
operator=(initializer_list<value_type> __l)
......@@ -372,15 +364,11 @@ namespace __debug
void
swap(set& __x)
#if __cplusplus >= 201103L
noexcept(_Alloc_traits::_S_nothrow_swap())
noexcept( noexcept(declval<_Base>().swap(__x)) )
#endif
{
#if __cplusplus >= 201103L
if (!_Alloc_traits::_S_propagate_on_swap())
__glibcxx_check_equal_allocs(__x);
#endif
_Safe::_M_swap(__x);
_Base::swap(__x);
this->_M_swap(__x);
}
void
......@@ -452,14 +440,6 @@ namespace __debug
const _Base&
_M_base() const _GLIBCXX_NOEXCEPT { return *this; }
private:
void
_M_invalidate_all()
{
typedef __gnu_debug::_Not_equal_to<_Base_const_iterator> _Not_equal;
this->_M_invalidate_if(_Not_equal(_M_base().end()));
}
};
template<typename _Key, typename _Compare, typename _Allocator>
......
......@@ -31,6 +31,7 @@
#include <string>
#include <debug/safe_sequence.h>
#include <debug/safe_container.h>
#include <debug/safe_iterator.h>
namespace __gnu_debug
......@@ -39,12 +40,14 @@ namespace __gnu_debug
template<typename _CharT, typename _Traits = std::char_traits<_CharT>,
typename _Allocator = std::allocator<_CharT> >
class basic_string
: public std::basic_string<_CharT, _Traits, _Allocator>,
public __gnu_debug::_Safe_sequence<basic_string<_CharT, _Traits,
_Allocator> >
: public __gnu_debug::_Safe_container<
basic_string<_CharT, _Traits, _Allocator>,
_Allocator, _Safe_sequence, false>,
public std::basic_string<_CharT, _Traits, _Allocator>
{
typedef std::basic_string<_CharT, _Traits, _Allocator> _Base;
typedef __gnu_debug::_Safe_sequence<basic_string> _Safe_base;
typedef __gnu_debug::_Safe_container<
basic_string, _Allocator, _Safe_sequence, false> _Safe;
public:
// types:
......@@ -58,10 +61,10 @@ namespace __gnu_debug
typedef typename _Base::pointer pointer;
typedef typename _Base::const_pointer const_pointer;
typedef __gnu_debug::_Safe_iterator<typename _Base::iterator, basic_string>
iterator;
typedef __gnu_debug::_Safe_iterator<typename _Base::const_iterator,
basic_string> const_iterator;
typedef __gnu_debug::_Safe_iterator<
typename _Base::iterator, basic_string> iterator;
typedef __gnu_debug::_Safe_iterator<
typename _Base::const_iterator, basic_string> const_iterator;
typedef std::reverse_iterator<iterator> reverse_iterator;
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
......@@ -71,30 +74,39 @@ namespace __gnu_debug
// 21.3.1 construct/copy/destroy:
explicit basic_string(const _Allocator& __a = _Allocator())
// _GLIBCXX_NOEXCEPT
: _Base(__a)
{ }
// Provides conversion from a release-mode string to a debug-mode string
basic_string(const _Base& __base) : _Base(__base) { }
: _Base(__a) { }
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 42. string ctors specify wrong default allocator
#if __cplusplus < 201103L
basic_string(const basic_string& __str)
: _Base(__str, 0, _Base::npos, __str.get_allocator())
: _Base(__str) { }
~basic_string() { }
#else
basic_string(const basic_string&) = default;
basic_string(basic_string&&) = default;
basic_string(std::initializer_list<_CharT> __l,
const _Allocator& __a = _Allocator())
: _Base(__l, __a)
{ }
~basic_string() = default;
#endif // C++11
// Provides conversion from a normal-mode string to a debug-mode string
basic_string(const _Base& __base)
: _Base(__base) { }
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 42. string ctors specify wrong default allocator
basic_string(const basic_string& __str, size_type __pos,
size_type __n = _Base::npos,
const _Allocator& __a = _Allocator())
: _Base(__str, __pos, __n, __a)
{ }
: _Base(__str, __pos, __n, __a) { }
basic_string(const _CharT* __s, size_type __n,
const _Allocator& __a = _Allocator())
: _Base(__gnu_debug::__check_string(__s, __n), __n, __a)
{ }
: _Base(__gnu_debug::__check_string(__s, __n), __n, __a) { }
basic_string(const _CharT* __s, const _Allocator& __a = _Allocator())
: _Base(__gnu_debug::__check_string(__s), __a)
......@@ -102,43 +114,36 @@ namespace __gnu_debug
basic_string(size_type __n, _CharT __c,
const _Allocator& __a = _Allocator())
: _Base(__n, __c, __a)
{ }
: _Base(__n, __c, __a) { }
template<typename _InputIterator>
basic_string(_InputIterator __begin, _InputIterator __end,
const _Allocator& __a = _Allocator())
: _Base(__gnu_debug::__base(__gnu_debug::__check_valid_range(__begin,
__end)),
__gnu_debug::__base(__end), __a)
{ }
#if __cplusplus >= 201103L
basic_string(basic_string&& __str) // noexcept
: _Base(std::move(__str))
{ }
basic_string(std::initializer_list<_CharT> __l,
const _Allocator& __a = _Allocator())
: _Base(__l, __a)
{ }
#endif // C++11
~basic_string() _GLIBCXX_NOEXCEPT { }
__gnu_debug::__base(__end), __a) { }
#if __cplusplus < 201103L
basic_string&
operator=(const basic_string& __str)
{
*static_cast<_Base*>(this) = __str;
this->_M_invalidate_all();
this->_M_safe() = __str;
_M_base() = __str;
return *this;
}
#else
basic_string&
operator=(const basic_string&) = default;
basic_string&
operator=(basic_string&&) = default;
#endif
basic_string&
operator=(const _CharT* __s)
{
__glibcxx_check_string(__s);
*static_cast<_Base*>(this) = __s;
_M_base() = __s;
this->_M_invalidate_all();
return *this;
}
......@@ -146,25 +151,16 @@ namespace __gnu_debug
basic_string&
operator=(_CharT __c)
{
*static_cast<_Base*>(this) = __c;
_M_base() = __c;
this->_M_invalidate_all();
return *this;
}
#if __cplusplus >= 201103L
basic_string&
operator=(basic_string&& __str)
{
__glibcxx_check_self_move_assign(__str);
*static_cast<_Base*>(this) = std::move(__str);
this->_M_invalidate_all();
return *this;
}
basic_string&
operator=(std::initializer_list<_CharT> __l)
{
*static_cast<_Base*>(this) = __l;
_M_base() = __l;
this->_M_invalidate_all();
return *this;
}
......@@ -704,12 +700,10 @@ namespace __gnu_debug
}
void
swap(basic_string<_CharT,_Traits,_Allocator>& __x)
swap(basic_string& __x)
{
_Safe::_M_swap(__x);
_Base::swap(__x);
this->_M_swap(__x);
this->_M_invalidate_all();
__x._M_invalidate_all();
}
// 21.3.6 string operations:
......@@ -922,7 +916,7 @@ namespace __gnu_debug
const _Base&
_M_base() const _GLIBCXX_NOEXCEPT { return *this; }
using _Safe_base::_M_invalidate_all;
using _Safe::_M_invalidate_all;
};
template<typename _CharT, typename _Traits, typename _Allocator>
......
......@@ -23,8 +23,8 @@
// <http://www.gnu.org/licenses/>.
#include <debug/debug.h>
#include <debug/safe_sequence.h>
#include <debug/safe_unordered_container.h>
#include <debug/safe_base.h>
#include <debug/safe_unordered_base.h>
#include <debug/safe_iterator.h>
#include <debug/safe_local_iterator.h>
#include <algorithm>
......@@ -235,7 +235,7 @@ namespace __gnu_debug
void
_Safe_sequence_base::
_M_swap(_Safe_sequence_base& __x)
_M_swap(_Safe_sequence_base& __x) noexcept
{
// We need to lock both sequences to swap
using namespace __gnu_cxx;
......@@ -382,7 +382,7 @@ namespace __gnu_debug
_Safe_unordered_container_base*
_Safe_local_iterator_base::
_M_get_container() const _GLIBCXX_NOEXCEPT
_M_get_container() const noexcept
{ return static_cast<_Safe_unordered_container_base*>(_M_sequence); }
void
......@@ -455,7 +455,7 @@ namespace __gnu_debug
void
_Safe_unordered_container_base::
_M_swap(_Safe_unordered_container_base& __x)
_M_swap(_Safe_unordered_container_base& __x) noexcept
{
// We need to lock both containers to swap
using namespace __gnu_cxx;
......
......@@ -32,9 +32,11 @@ void test01()
typedef std::forward_list<T, alloc_type> test_type;
test_type v1(alloc_type(1));
v1 = { T() };
auto it = v1.begin();
test_type v2(std::move(v1));
VERIFY(1 == v1.get_allocator().get_personality());
VERIFY(1 == v2.get_allocator().get_personality());
VERIFY( it == v2.begin() );
}
void test02()
......
......@@ -46,11 +46,13 @@ void test02()
typedef std::forward_list<T, alloc_type> test_type;
test_type v1(alloc_type(1));
v1.push_front(T());
auto it = v1.begin();
test_type v2(alloc_type(2));
v2.push_front(T());
v2 = std::move(v1);
VERIFY(0 == v1.get_allocator().get_personality());
VERIFY(1 == v2.get_allocator().get_personality());
VERIFY( it == v2.begin() );
}
int main()
......
// Copyright (C) 2014 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/>.
//
// { dg-require-debug-mode "" }
// { dg-options "-std=gnu++11" }
// { dg-do run { xfail *-*-* } }
#include <forward_list>
#include <debug/checks.h>
void test01()
{
__gnu_test::check_construct1<std::forward_list<int> >();
}
int main()
{
test01();
return 0;
}
// Copyright (C) 2014 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/>.
//
// { dg-require-debug-mode "" }
// { dg-options "-std=gnu++11" }
// { dg-do run { xfail *-*-* } }
#include <forward_list>
#include <debug/checks.h>
void test01()
{
__gnu_test::check_construct2<std::forward_list<int> >();
}
int main()
{
test01();
return 0;
}
// Copyright (C) 2010-2014 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/>.
//
// { dg-require-debug-mode "" }
// { dg-options "-std=gnu++11" }
// { dg-do run { xfail *-*-* } }
#include <forward_list>
#include <debug/checks.h>
void test01()
{
__gnu_test::check_construct3<std::forward_list<int> >();
}
int main()
{
test01();
return 0;
}
// Copyright (C) 2014 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/>.
//
// { dg-options "-std=gnu++11" }
// { dg-do run { xfail *-*-* } }
#include <debug/forward_list>
#include <testsuite_allocator.h>
void test01()
{
bool test __attribute__((unused)) = true;
typedef __gnu_test::uneq_allocator<int> alloc_type;
typedef __gnu_debug::forward_list<int, alloc_type> test_type;
test_type v1(alloc_type(1));
v1.push_front(0);
auto it = v1.begin();
test_type v2(std::move(v1), alloc_type(2));
VERIFY( it == v2.begin() ); // Error, it is singular
}
int main()
{
test01();
return 0;
}
// Copyright (C) 2014 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/>.
//
// { dg-options "-std=gnu++11" }
// { dg-do run { xfail *-*-* } }
#include <debug/forward_list>
#include <testsuite_allocator.h>
void test01()
{
bool test __attribute__((unused)) = true;
typedef __gnu_test::uneq_allocator<int> alloc_type;
typedef __gnu_debug::forward_list<int, alloc_type> test_type;
test_type v1(alloc_type(1));
v1.push_front(0);
auto it = v1.begin();
test_type v2(alloc_type(2));
v2.push_front(1);
v2 = std::move(v1);
VERIFY( *it == 0 ); // Error, it is singular.
}
int main()
{
test01();
return 0;
}
// Copyright (C) 2014 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/>.
// { dg-options "-std=gnu++11" }
// { dg-do run { xfail *-*-* } }
#include <debug/forward_list>
#include <testsuite_hooks.h>
#include <testsuite_allocator.h>
using __gnu_test::uneq_allocator;
void test01()
{
bool test __attribute__((unused)) = true;
typedef uneq_allocator<int> alloc_type;
typedef __gnu_debug::forward_list<int, alloc_type> test_type;
test_type v1(alloc_type(1));
v1 = { 0 };
auto it = v1.begin();
test_type v2(std::move(v1), alloc_type(2));
VERIFY( *it == 0 );
}
int main()
{
test01();
return 0;
}
......@@ -38,9 +38,13 @@ void test01()
typedef std::map<T, U, Cmp, alloc_type> test_type;
test_type v1(alloc_type(1));
v1 = { test_type::value_type{} };
auto it = v1.begin();
test_type v2(std::move(v1));
VERIFY(1 == v1.get_allocator().get_personality());
VERIFY(1 == v2.get_allocator().get_personality());
VERIFY( it == v2.begin() );
}
void test02()
......
......@@ -38,9 +38,11 @@ void test01()
typedef std::map<T, U, Cmp, alloc_type> test_type;
test_type v1(alloc_type(1));
v1 = { test_type::value_type{} };
test_type v2(alloc_type(2));
v2 = { test_type::value_type{} };
v2 = std::move(v1);
VERIFY(1 == v1.get_allocator().get_personality());
VERIFY(2 == v2.get_allocator().get_personality());
}
......@@ -52,11 +54,15 @@ void test02()
typedef std::map<T, U, Cmp, alloc_type> test_type;
test_type v1(alloc_type(1));
v1 = { test_type::value_type{} };
auto it = v1.begin();
test_type v2(alloc_type(2));
v2 = { test_type::value_type{} };
v2 = std::move(v1);
VERIFY(0 == v1.get_allocator().get_personality());
VERIFY(1 == v2.get_allocator().get_personality());
VERIFY( it == v2.begin() );
}
int main()
......
// Copyright (C) 2014 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/>.
//
// { dg-options "-std=gnu++11" }
// { dg-do run { xfail *-*-* } }
#include <debug/map>
#include <testsuite_allocator.h>
void test01()
{
bool test __attribute__((unused)) = true;
typedef __gnu_test::uneq_allocator<std::pair<const int, int> > alloc_type;
typedef __gnu_debug::map<int, int, std::less<int>, alloc_type> test_type;
test_type v1(alloc_type(1));
v1.insert(std::make_pair(0, 0));
auto it = v1.begin();
test_type v2(std::move(v1), alloc_type(2));
VERIFY( it->first == 0 ); // Error, it is singular
}
int main()
{
test01();
return 0;
}
// Copyright (C) 2014 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/>.
//
// { dg-options "-std=gnu++11" }
// { dg-do run { xfail *-*-* } }
#include <debug/map>
#include <testsuite_allocator.h>
void test01()
{
bool test __attribute__((unused)) = true;
typedef __gnu_test::uneq_allocator<std::pair<const int, int> > alloc_type;
typedef __gnu_debug::map<int, int, std::less<int>, alloc_type> test_type;
test_type v1(alloc_type(1));
v1.insert(std::make_pair(0, 0));
auto it = v1.begin();
test_type v2(alloc_type(2));
v2.insert(std::make_pair(1, 1));
v2 = std::move(v1);
VERIFY( it == v2.begin() ); // Error, it is singular.
}
int main()
{
test01();
return 0;
}
// Copyright (C) 2014 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/>.
// { dg-options "-std=gnu++11" }
// { dg-do run { xfail *-*-* } }
#include <debug/map>
#include <testsuite_hooks.h>
#include <testsuite_allocator.h>
using __gnu_test::uneq_allocator;
void test01()
{
bool test __attribute__((unused)) = true;
typedef uneq_allocator<std::pair<const int, int> > alloc_type;
typedef __gnu_debug::map<int, int, std::less<int>, alloc_type> test_type;
test_type v1(alloc_type(1));
v1 = { { 0, 0 } };
auto it = v1.begin();
test_type v2(std::move(v1), alloc_type(2));
VERIFY( it->first == 0 );
}
int main()
{
test01();
return 0;
}
......@@ -38,9 +38,13 @@ void test01()
typedef std::multimap<T, U, Cmp, alloc_type> test_type;
test_type v1(alloc_type(1));
v1 = { test_type::value_type{} };
auto it = v1.begin();
test_type v2(std::move(v1));
VERIFY(1 == v1.get_allocator().get_personality());
VERIFY(1 == v2.get_allocator().get_personality());
VERIFY( it == v2.begin() );
}
void test02()
......
......@@ -52,11 +52,13 @@ void test02()
typedef std::multimap<T, U, Cmp, alloc_type> test_type;
test_type v1(alloc_type(1));
v1 = { test_type::value_type{} };
auto it = v1.begin();
test_type v2(alloc_type(2));
v2 = { test_type::value_type{} };
v2 = std::move(v1);
VERIFY(0 == v1.get_allocator().get_personality());
VERIFY(1 == v2.get_allocator().get_personality());
VERIFY( it == v2.begin() );
}
int main()
......
// Copyright (C) 2014 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/>.
//
// { dg-options "-std=gnu++11" }
// { dg-do run { xfail *-*-* } }
#include <debug/map>
#include <testsuite_allocator.h>
void test01()
{
bool test __attribute__((unused)) = true;
typedef __gnu_test::uneq_allocator<std::pair<const int, int> > alloc_type;
typedef __gnu_debug::multimap<int, int, std::less<int>, alloc_type> test_type;
test_type v1(alloc_type(1));
v1.insert(std::make_pair(0, 0));
auto it = v1.begin();
test_type v2(std::move(v1), alloc_type(2));
VERIFY( it->first == 0 ); // Error, it is singular
}
int main()
{
test01();
return 0;
}
// Copyright (C) 2014 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/>.
//
// { dg-options "-std=gnu++11" }
// { dg-do run { xfail *-*-* } }
#include <debug/map>
#include <testsuite_allocator.h>
void test01()
{
bool test __attribute__((unused)) = true;
typedef __gnu_test::uneq_allocator<std::pair<const int, int> > alloc_type;
typedef __gnu_debug::multimap<int, int, std::less<int>, alloc_type> test_type;
test_type v1(alloc_type(1));
v1.insert(std::make_pair(0, 0));
auto it = v1.begin();
test_type v2(alloc_type(2));
v2.insert(std::make_pair(1, 1));
v2 = std::move(v1);
VERIFY( it == v2.begin() ); // Error, it is singular.
}
int main()
{
test01();
return 0;
}
// Copyright (C) 2014 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/>.
// { dg-options "-std=gnu++11" }
// { dg-do run { xfail *-*-* } }
#include <debug/map>
#include <testsuite_hooks.h>
#include <testsuite_allocator.h>
using __gnu_test::uneq_allocator;
void test01()
{
bool test __attribute__((unused)) = true;
typedef uneq_allocator<std::pair<const int, int> > alloc_type;
typedef __gnu_debug::multimap<int, int, std::less<int>, alloc_type> test_type;
test_type v1(alloc_type(1));
v1 = { { 0, 0 } };
auto it = v1.begin();
test_type v2(std::move(v1), alloc_type(2));
VERIFY( it->first == 0 );
}
int main()
{
test01();
return 0;
}
......@@ -36,9 +36,13 @@ void test01()
typedef std::multiset<T, Cmp, alloc_type> test_type;
test_type v1(alloc_type(1));
v1 = { test_type::value_type{} };
auto it = v1.begin();
test_type v2(std::move(v1));
VERIFY(1 == v1.get_allocator().get_personality());
VERIFY(1 == v2.get_allocator().get_personality());
VERIFY( it == v2.begin() );
}
void test02()
......
......@@ -50,11 +50,13 @@ void test02()
typedef std::multiset<T, Cmp, alloc_type> test_type;
test_type v1(alloc_type(1));
v1 = { test_type::value_type{} };
auto it = v1.begin();
test_type v2(alloc_type(2));
v2 = { test_type::value_type{} };
v2 = std::move(v1);
VERIFY(0 == v1.get_allocator().get_personality());
VERIFY(1 == v2.get_allocator().get_personality());
VERIFY( it == v2.begin() );
}
int main()
......
// Copyright (C) 2014 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/>.
//
// { dg-options "-std=gnu++11" }
// { dg-do run { xfail *-*-* } }
#include <debug/set>
#include <testsuite_allocator.h>
void test01()
{
bool test __attribute__((unused)) = true;
typedef __gnu_test::uneq_allocator<int> alloc_type;
typedef __gnu_debug::multiset<int, std::less<int>, alloc_type> test_type;
test_type v1(alloc_type(1));
v1.insert(0);
auto it = v1.begin();
test_type v2(std::move(v1), alloc_type(2));
VERIFY( *it == 0 ); // Error, it is singular
}
int main()
{
test01();
return 0;
}
// Copyright (C) 2014 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/>.
//
// { dg-options "-std=gnu++11" }
// { dg-do run { xfail *-*-* } }
#include <debug/set>
#include <testsuite_allocator.h>
void test01()
{
bool test __attribute__((unused)) = true;
typedef __gnu_test::uneq_allocator<int> alloc_type;
typedef __gnu_debug::multiset<int, std::less<int>, alloc_type> test_type;
test_type v1(alloc_type(1));
v1.insert(0);
auto it = v1.begin();
test_type v2(alloc_type(2));
v2.insert(1);
v2 = std::move(v1);
VERIFY( it == v2.begin() ); // Error, it is singular.
}
int main()
{
test01();
return 0;
}
// Copyright (C) 2014 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/>.
// { dg-options "-std=gnu++11" }
// { dg-do run { xfail *-*-* } }
#include <debug/set>
#include <testsuite_hooks.h>
#include <testsuite_allocator.h>
using __gnu_test::uneq_allocator;
void test01()
{
bool test __attribute__((unused)) = true;
typedef uneq_allocator<int> alloc_type;
typedef __gnu_debug::multiset<int, std::less<int>, alloc_type> test_type;
test_type v1(alloc_type(1));
v1 = { 0 };
auto it = v1.begin();
test_type v2(std::move(v1), alloc_type(2));
VERIFY( *it == 0 );
}
int main()
{
test01();
return 0;
}
......@@ -38,9 +38,13 @@ void test01()
typedef std::set<T, Cmp, alloc_type> test_type;
test_type v1(alloc_type(1));
v1 = { test_type::value_type{} };
auto it = v1.begin();
test_type v2(std::move(v1));
VERIFY(1 == v1.get_allocator().get_personality());
VERIFY(1 == v2.get_allocator().get_personality());
VERIFY( it == v2.begin() );
}
void test02()
......
......@@ -50,11 +50,13 @@ void test02()
typedef std::set<T, Cmp, alloc_type> test_type;
test_type v1(alloc_type(1));
v1 = { test_type::value_type{} };
auto it = v1.begin();
test_type v2(alloc_type(2));
v2 = { test_type::value_type{} };
v2 = std::move(v1);
VERIFY(0 == v1.get_allocator().get_personality());
VERIFY(1 == v2.get_allocator().get_personality());
VERIFY( it == v2.begin() );
}
int main()
......
// Copyright (C) 2014 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/>.
//
// { dg-options "-std=gnu++11" }
// { dg-do run { xfail *-*-* } }
#include <debug/set>
#include <testsuite_allocator.h>
void test01()
{
bool test __attribute__((unused)) = true;
typedef __gnu_test::uneq_allocator<int> alloc_type;
typedef __gnu_debug::set<int, std::less<int>, alloc_type> test_type;
test_type v1(alloc_type(1));
v1.insert(0);
auto it = v1.begin();
test_type v2(std::move(v1), alloc_type(2));
VERIFY( *it == 0 ); // Error, it is singular
}
int main()
{
test01();
return 0;
}
// Copyright (C) 2014 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/>.
//
// { dg-options "-std=gnu++11" }
// { dg-do run { xfail *-*-* } }
#include <debug/set>
#include <testsuite_allocator.h>
void test01()
{
bool test __attribute__((unused)) = true;
typedef __gnu_test::uneq_allocator<int> alloc_type;
typedef __gnu_debug::set<int, std::less<int>, alloc_type> test_type;
test_type v1(alloc_type(1));
v1.insert(0);
auto it = v1.begin();
test_type v2(alloc_type(2));
v2.insert(1);
v2 = std::move(v1);
VERIFY( it == v2.begin() ); // Error, it is singular.
}
int main()
{
test01();
return 0;
}
// Copyright (C) 2014 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/>.
// { dg-options "-std=gnu++11" }
// { dg-do run { xfail *-*-* } }
#include <debug/set>
#include <testsuite_hooks.h>
#include <testsuite_allocator.h>
using __gnu_test::uneq_allocator;
void test01()
{
bool test __attribute__((unused)) = true;
typedef uneq_allocator<int> alloc_type;
typedef __gnu_debug::set<int, std::less<int>, alloc_type> test_type;
test_type v1(alloc_type(1));
v1 = { 0 };
auto it = v1.begin();
test_type v2(std::move(v1), alloc_type(2));
VERIFY( *it == 0 );
}
int main()
{
test01();
return 0;
}
......@@ -45,9 +45,11 @@ void test01()
test_type v1(alloc_type(1));
v1.emplace(std::piecewise_construct,
std::make_tuple(T()), std::make_tuple(T()));
auto it = v1.begin();
test_type v2(std::move(v1));
VERIFY(1 == v1.get_allocator().get_personality());
VERIFY(1 == v2.get_allocator().get_personality());
VERIFY( it == v2.begin() );
}
void test02()
......
......@@ -66,6 +66,8 @@ void test02()
v1.emplace(std::piecewise_construct,
std::make_tuple(1), std::make_tuple(1));
auto it = v1.begin();
test_type v2(alloc_type(2));
v2.emplace(std::piecewise_construct,
std::make_tuple(2), std::make_tuple(2));
......@@ -79,6 +81,8 @@ void test02()
VERIFY( counter_type::move_assign_count == 0 );
VERIFY( counter_type::destructor_count == 2 );
VERIFY( it == v2.begin() );
}
int main()
......
// Copyright (C) 2014 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/>.
//
// { dg-options "-std=gnu++11" }
// { dg-do run { xfail *-*-* } }
#include <debug/unordered_map>
#include <testsuite_allocator.h>
void test01()
{
bool test __attribute__((unused)) = true;
typedef __gnu_test::uneq_allocator<std::pair<const int, int>> alloc_type;
typedef __gnu_debug::unordered_map<int, int, std::hash<int>,
std::equal_to<int>,
alloc_type> test_type;
test_type v1(alloc_type(1));
v1.insert(std::make_pair(0, 0));
auto it = v1.begin();
test_type v2(std::move(v1), alloc_type(2));
VERIFY( it == v2.begin() ); // Error, it is singular.
}
int main()
{
test01();
return 0;
}
// Copyright (C) 2014 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/>.
//
// { dg-options "-std=gnu++11" }
// { dg-do run { xfail *-*-* } }
#include <debug/unordered_map>
#include <testsuite_allocator.h>
void test01()
{
bool test __attribute__((unused)) = true;
typedef __gnu_test::uneq_allocator<std::pair<const int, int> > alloc_type;
typedef __gnu_debug::unordered_map<int, int,
std::hash<int>, std::equal_to<int>,
alloc_type> test_type;
test_type v1(alloc_type(1));
v1.insert(std::make_pair(0, 0));
auto it = v1.begin();
test_type v2(alloc_type(2));
v2 = std::move(v1);
VERIFY( it == v2.begin() ); // Error, it is singular.
}
int main()
{
test01();
return 0;
}
// Copyright (C) 2014 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/>.
// { dg-options "-std=gnu++11" }
// { dg-do run { xfail *-*-* } }
#include <debug/unordered_map>
#include <testsuite_hooks.h>
#include <testsuite_allocator.h>
using __gnu_test::uneq_allocator;
void test01()
{
bool test __attribute__((unused)) = true;
typedef uneq_allocator<std::pair<const int, int> > alloc_type;
typedef __gnu_debug::unordered_map<
int, int, std::hash<int>, std::equal_to<int>, alloc_type> test_type;
test_type v1(alloc_type(1));
v1 = { { 0, 0 } };
auto it = v1.begin();
test_type v2(std::move(v1), alloc_type(2));
VERIFY( it->first == 0 );
}
int main()
{
test01();
return 0;
}
......@@ -45,9 +45,11 @@ void test01()
test_type v1(alloc_type(1));
v1.emplace(std::piecewise_construct,
std::make_tuple(T()), std::make_tuple(T()));
auto it = v1.begin();
test_type v2(std::move(v1));
VERIFY(1 == v1.get_allocator().get_personality());
VERIFY(1 == v2.get_allocator().get_personality());
VERIFY( it == v2.begin() );
}
void test02()
......
......@@ -66,6 +66,8 @@ void test02()
v1.emplace(std::piecewise_construct,
std::make_tuple(1), std::make_tuple(1));
auto it = v1.begin();
test_type v2(alloc_type(2));
v2.emplace(std::piecewise_construct,
std::make_tuple(2), std::make_tuple(2));
......@@ -79,6 +81,8 @@ void test02()
VERIFY( counter_type::move_assign_count == 0 );
VERIFY( counter_type::destructor_count == 2 );
VERIFY( it == v2.begin() );
}
int main()
......
// Copyright (C) 2014 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/>.
//
// { dg-options "-std=gnu++11" }
// { dg-do run { xfail *-*-* } }
#include <debug/unordered_map>
#include <testsuite_allocator.h>
void test01()
{
bool test __attribute__((unused)) = true;
typedef __gnu_test::uneq_allocator<std::pair<const int, int>> alloc_type;
typedef __gnu_debug::unordered_multimap<int, int,
std::hash<int>, std::equal_to<int>,
alloc_type> test_type;
test_type v1(alloc_type(1));
v1.insert(std::make_pair(0, 0));
auto it = v1.begin();
test_type v2(std::move(v1), alloc_type(2));
VERIFY( it == v2.begin() ); // Error, it is singular.
}
int main()
{
test01();
return 0;
}
// Copyright (C) 2014 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/>.
//
// { dg-options "-std=gnu++11" }
// { dg-do run { xfail *-*-* } }
#include <debug/unordered_map>
#include <testsuite_allocator.h>
void test01()
{
bool test __attribute__((unused)) = true;
typedef __gnu_test::uneq_allocator<std::pair<const int, int>> alloc_type;
typedef __gnu_debug::unordered_multimap<int, int, std::hash<int>,
std::equal_to<int>,
alloc_type> test_type;
test_type v1(alloc_type(1));
v1.insert(std::make_pair(0, 0));
auto it = v1.begin();
test_type v2(alloc_type(2));
v2 = std::move(v1);
VERIFY( it == v2.begin() ); // Error, it is singular.
}
int main()
{
test01();
return 0;
}
// Copyright (C) 2014 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/>.
// { dg-options "-std=gnu++11" }
// { dg-do run { xfail *-*-* } }
#include <debug/unordered_map>
#include <testsuite_hooks.h>
#include <testsuite_allocator.h>
using __gnu_test::uneq_allocator;
void test01()
{
bool test __attribute__((unused)) = true;
typedef uneq_allocator<std::pair<const int, int> > alloc_type;
typedef __gnu_debug::unordered_multimap<
int, int, std::hash<int>, std::equal_to<int>, alloc_type> test_type;
test_type v1(alloc_type(1));
v1 = { { 0, 0 } };
auto it = v1.begin();
test_type v2(std::move(v1), alloc_type(2));
VERIFY( it->first == 0 );
}
int main()
{
test01();
return 0;
}
......@@ -44,9 +44,11 @@ void test01()
typedef std::unordered_multiset<T, hash, equal_to, alloc_type> test_type;
test_type v1(alloc_type(1));
v1.insert(T());
auto it = v1.begin();
test_type v2(std::move(v1));
VERIFY(1 == v1.get_allocator().get_personality());
VERIFY(1 == v2.get_allocator().get_personality());
VERIFY( it == v2.begin() );
}
void test02()
......
......@@ -63,6 +63,8 @@ void test02()
test_type v1(alloc_type(1));
v1.emplace(0);
auto it = v1.begin();
test_type v2(alloc_type(2));
v2.emplace(0);
......@@ -76,6 +78,8 @@ void test02()
VERIFY( counter_type::move_count == 0 );
VERIFY( counter_type::copy_count == 0 );
VERIFY( counter_type::destructor_count == 1 );
VERIFY( it == v2.begin() );
}
int main()
......
// Copyright (C) 2014 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/>.
//
// { dg-options "-std=gnu++11" }
// { dg-do run { xfail *-*-* } }
#include <debug/unordered_set>
#include <testsuite_allocator.h>
void test01()
{
bool test __attribute__((unused)) = true;
typedef __gnu_test::uneq_allocator<int> alloc_type;
typedef __gnu_debug::unordered_multiset<int, std::hash<int>,
std::equal_to<int>,
alloc_type> test_type;
test_type v1(alloc_type(1));
v1.insert(0);
auto it = v1.begin();
test_type v2(std::move(v1), alloc_type(2));
VERIFY( it == v2.begin() ); // Error, it is singular
}
int main()
{
test01();
return 0;
}
// Copyright (C) 2014 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/>.
//
// { dg-options "-std=gnu++11" }
// { dg-do run { xfail *-*-* } }
#include <debug/unordered_set>
#include <testsuite_allocator.h>
void test01()
{
bool test __attribute__((unused)) = true;
typedef __gnu_test::uneq_allocator<int> alloc_type;
typedef __gnu_debug::unordered_multiset<int, std::hash<int>,
std::equal_to<int>,
alloc_type> test_type;
test_type v1(alloc_type(1));
v1.emplace(0);
auto it = v1.begin();
test_type v2(alloc_type(2));
v2.emplace(1);
v2 = std::move(v1);
VERIFY( it == v2.begin() ); // Error, it is singular.
}
int main()
{
test01();
return 0;
}
// Copyright (C) 2014 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/>.
// { dg-options "-std=gnu++11" }
// { dg-do run { xfail *-*-* } }
#include <debug/unordered_set>
#include <testsuite_hooks.h>
#include <testsuite_allocator.h>
using __gnu_test::uneq_allocator;
void test01()
{
bool test __attribute__((unused)) = true;
typedef uneq_allocator<int> alloc_type;
typedef __gnu_debug::unordered_multiset<
int, std::hash<int>, std::equal_to<int>, alloc_type> test_type;
test_type v1(alloc_type(1));
v1 = { 0 };
auto it = v1.begin();
test_type v2(std::move(v1), alloc_type(2));
VERIFY( *it == 0 );
}
int main()
{
test01();
return 0;
}
......@@ -44,9 +44,11 @@ void test01()
typedef std::unordered_set<T, hash, equal_to, alloc_type> test_type;
test_type v1(alloc_type(1));
v1.insert(T());
auto it = v1.begin();
test_type v2(std::move(v1));
VERIFY(1 == v1.get_allocator().get_personality());
VERIFY(1 == v2.get_allocator().get_personality());
VERIFY( it == v2.begin() );
}
void test02()
......
......@@ -63,6 +63,8 @@ void test02()
test_type v1(alloc_type(1));
v1.emplace(0);
auto it = v1.begin();
test_type v2(alloc_type(2));
v2.emplace(0);
......@@ -76,6 +78,8 @@ void test02()
VERIFY( counter_type::move_count == 0 );
VERIFY( counter_type::copy_count == 0 );
VERIFY( counter_type::destructor_count == 1 );
VERIFY( it == v2.begin() );
}
int main()
......
// Copyright (C) 2014 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/>.
//
// { dg-options "-std=gnu++11" }
// { dg-do run { xfail *-*-* } }
#include <debug/unordered_set>
#include <testsuite_allocator.h>
void test01()
{
bool test __attribute__((unused)) = true;
typedef __gnu_test::uneq_allocator<int> alloc_type;
typedef __gnu_debug::unordered_set<int, std::hash<int>,
std::equal_to<int>, alloc_type> test_type;
test_type v1(alloc_type(1));
v1.insert(0);
auto it = v1.begin();
test_type v2(std::move(v1), alloc_type(2));
VERIFY( it == v2.begin() ); // Error, it is singular
}
int main()
{
test01();
return 0;
}
// Copyright (C) 2014 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/>.
//
// { dg-options "-std=gnu++11" }
// { dg-do run { xfail *-*-* } }
#include <debug/unordered_set>
#include <testsuite_allocator.h>
void test01()
{
bool test __attribute__((unused)) = true;
typedef __gnu_test::uneq_allocator<int> alloc_type;
typedef __gnu_debug::unordered_set<int, std::hash<int>,
std::equal_to<int>,
alloc_type> test_type;
test_type v1(alloc_type(1));
v1.emplace(0);
auto it = v1.begin();
test_type v2(alloc_type(2));
v2.emplace(1);
v2 = std::move(v1);
VERIFY( it == v2.begin() ); // Error, it is singular.
}
int main()
{
test01();
return 0;
}
// Copyright (C) 2014 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/>.
// { dg-options "-std=gnu++11" }
// { dg-do run { xfail *-*-* } }
#include <debug/unordered_set>
#include <testsuite_hooks.h>
#include <testsuite_allocator.h>
using __gnu_test::uneq_allocator;
void test01()
{
bool test __attribute__((unused)) = true;
typedef uneq_allocator<int> alloc_type;
typedef __gnu_debug::unordered_set<
int, std::hash<int>, std::equal_to<int>, alloc_type> test_type;
test_type v1(alloc_type(1));
v1 = { 0 };
auto it = v1.begin();
test_type v2(std::move(v1), alloc_type(2));
VERIFY( *it == 0 );
}
int main()
{
test01();
return 0;
}
// Copyright (C) 2014 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/>.
// { dg-options "-std=gnu++11" }
// { dg-do run { xfail *-*-* } }
#include <debug/vector>
#include <testsuite_hooks.h>
#include <testsuite_allocator.h>
using __gnu_test::uneq_allocator;
void test01()
{
bool test __attribute__((unused)) = true;
typedef uneq_allocator<int> alloc_type;
typedef __gnu_debug::vector<int, alloc_type> test_type;
test_type v1(alloc_type(1));
v1 = { 0 };
auto it = v1.begin();
test_type v2(std::move(v1), alloc_type(2));
VERIFY( *it == 0 );
}
int main()
{
test01();
return 0;
}
......@@ -179,10 +179,8 @@ namespace __gnu_test
val_type *first = &v.front() + 1;
val_type *last = first + 2;
cont_type c1(first, last);
VERIFY(c1.size() == 2);
cont_type c2(last, first); // Expected failure
cont_type c(last, first); // Expected failure
}
// Check that invalid range of debug random iterators is detected
......@@ -206,10 +204,8 @@ namespace __gnu_test
typename vector_type::iterator first = v.begin() + 1;
typename vector_type::iterator last = first + 2;
cont_type c1(first, last);
VERIFY(c1.size() == 2);
cont_type c2(last, first); // Expected failure
cont_type c(last, first); // Expected failure
}
// Check that invalid range of debug not random iterators is detected
......@@ -233,10 +229,8 @@ namespace __gnu_test
typename list_type::iterator first = l.begin(); ++first;
typename list_type::iterator last = first; ++last; ++last;
cont_type c1(first, last);
VERIFY(c1.size() == 2);
cont_type c2(last, first); // Expected failure
cont_type c(last, first); // Expected failure
}
template <typename _Cont>
......
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