Commit e6a05448 by Paolo Carlini Committed by Paolo Carlini

PR libstdc++/44436 (partial)

2010-11-10  Paolo Carlini  <paolo.carlini@oracle.com>

	PR libstdc++/44436 (partial)
	PR libstdc++/46148
        * include/bits/stl_tree.h (_Rb_tree<>::_M_insert_, _M_insert_lower,
	_M_insert_equal_lower, _M_insert_unique, _M_insert_equal,
	_M_insert_unique_, _M_insert_equal_): Templatize in C++0x mode,
	use _GLIBCXX_FORWARD throughout.
        * include/bits/stl_map.h (map<>::insert(_Pair&&),
	insert(const_iterator, _Pair&&), operator[](key_type&&): Add.
        * include/bits/stl_set.h (set<>::insert(value_type&&),
	insert(const_iterator, value_type&&)): Likewise.
        * include/bits/stl_multimap.h (multimap<>::insert(_Pair&&),
	insert(const_iterator, _Pair&&)): Likewise.
        * include/bits/stl_multiset.h (multiset<>::insert(value_type&&),
	insert(const_iterator, value_type&&)): Likewise.
	* include/debug/set.h: Adjust.
        * include/debug/multiset.h: Likewise.
        * include/debug/map.h: Likewise.
        * include/debug/multimap.h: Likewise.
        * include/profile/set.h: Likewise.
        * include/profile/multiset.h: Likewise.
        * include/profile/map.h: Likewise.
        * include/profile/multimap.h: Likewise.
        * testsuite/23_containers/multimap/modifiers/insert/1.cc: New.
        * testsuite/23_containers/multimap/modifiers/insert/2.cc: Likewise.
        * testsuite/23_containers/multimap/modifiers/insert/3.cc: Likewise.
        * testsuite/23_containers/multimap/modifiers/insert/4.cc: Likewise.
        * testsuite/23_containers/set/modifiers/insert/2.cc: Likewise.
        * testsuite/23_containers/set/modifiers/insert/3.cc: Likewise.
        * testsuite/23_containers/multiset/modifiers/insert/3.cc: Likewise.
        * testsuite/23_containers/multiset/modifiers/insert/4.cc: Likewise.
        * testsuite/23_containers/map/modifiers/insert/2.cc: Likewise.
        * testsuite/23_containers/map/modifiers/insert/3.cc: Likewise.
        * testsuite/23_containers/map/modifiers/insert/4.cc: Likewise.
        * testsuite/23_containers/map/modifiers/insert/5.cc: Likewise.
        * testsuite/23_containers/map/element_access/2.cc: Likewise.
        * testsuite/23_containers/map/element_access/46148.cc: Likewise.

        * include/bits/hashtable.h: Trivial naming changes.

From-SVN: r166551
parent 1d3a84ce
2010-11-10 Paolo Carlini <paolo.carlini@oracle.com> 2010-11-10 Paolo Carlini <paolo.carlini@oracle.com>
PR libstdc++/44436 (partial)
PR libstdc++/46148
* include/bits/stl_tree.h (_Rb_tree<>::_M_insert_, _M_insert_lower,
_M_insert_equal_lower, _M_insert_unique, _M_insert_equal,
_M_insert_unique_, _M_insert_equal_): Templatize in C++0x mode,
use _GLIBCXX_FORWARD throughout.
* include/bits/stl_map.h (map<>::insert(_Pair&&),
insert(const_iterator, _Pair&&), operator[](key_type&&): Add.
* include/bits/stl_set.h (set<>::insert(value_type&&),
insert(const_iterator, value_type&&)): Likewise.
* include/bits/stl_multimap.h (multimap<>::insert(_Pair&&),
insert(const_iterator, _Pair&&)): Likewise.
* include/bits/stl_multiset.h (multiset<>::insert(value_type&&),
insert(const_iterator, value_type&&)): Likewise.
* include/debug/set.h: Adjust.
* include/debug/multiset.h: Likewise.
* include/debug/map.h: Likewise.
* include/debug/multimap.h: Likewise.
* include/profile/set.h: Likewise.
* include/profile/multiset.h: Likewise.
* include/profile/map.h: Likewise.
* include/profile/multimap.h: Likewise.
* testsuite/23_containers/multimap/modifiers/insert/1.cc: New.
* testsuite/23_containers/multimap/modifiers/insert/2.cc: Likewise.
* testsuite/23_containers/multimap/modifiers/insert/3.cc: Likewise.
* testsuite/23_containers/multimap/modifiers/insert/4.cc: Likewise.
* testsuite/23_containers/set/modifiers/insert/2.cc: Likewise.
* testsuite/23_containers/set/modifiers/insert/3.cc: Likewise.
* testsuite/23_containers/multiset/modifiers/insert/3.cc: Likewise.
* testsuite/23_containers/multiset/modifiers/insert/4.cc: Likewise.
* testsuite/23_containers/map/modifiers/insert/2.cc: Likewise.
* testsuite/23_containers/map/modifiers/insert/3.cc: Likewise.
* testsuite/23_containers/map/modifiers/insert/4.cc: Likewise.
* testsuite/23_containers/map/modifiers/insert/5.cc: Likewise.
* testsuite/23_containers/map/element_access/2.cc: Likewise.
* testsuite/23_containers/map/element_access/46148.cc: Likewise.
* include/bits/hashtable.h: Trivial naming changes.
2010-11-10 Paolo Carlini <paolo.carlini@oracle.com>
* include/bits/hashtable.h (_Hashtable<>::_Insert_Conv_Type, * include/bits/hashtable.h (_Hashtable<>::_Insert_Conv_Type,
_Hashtable<>::_Insert_Return_Type): Change to private. _Hashtable<>::_Insert_Return_Type): Change to private.
......
...@@ -367,18 +367,18 @@ namespace std ...@@ -367,18 +367,18 @@ namespace std
_M_find_node(_Node*, const key_type&, _M_find_node(_Node*, const key_type&,
typename _Hashtable::_Hash_code_type) const; typename _Hashtable::_Hash_code_type) const;
template<typename _Pair> template<typename _Arg>
iterator iterator
_M_insert_bucket(_Pair&&, size_type, _M_insert_bucket(_Arg&&, size_type,
typename _Hashtable::_Hash_code_type); typename _Hashtable::_Hash_code_type);
template<typename _Pair> template<typename _Arg>
std::pair<iterator, bool> std::pair<iterator, bool>
_M_insert(_Pair&&, std::true_type); _M_insert(_Arg&&, std::true_type);
template<typename _Pair> template<typename _Arg>
iterator iterator
_M_insert(_Pair&&, std::false_type); _M_insert(_Arg&&, std::false_type);
typedef typename std::conditional<__unique_keys, typedef typename std::conditional<__unique_keys,
std::pair<iterator, bool>, std::pair<iterator, bool>,
...@@ -898,13 +898,13 @@ namespace std ...@@ -898,13 +898,13 @@ namespace std
typename _Allocator, typename _ExtractKey, typename _Equal, typename _Allocator, typename _ExtractKey, typename _Equal,
typename _H1, typename _H2, typename _Hash, typename _RehashPolicy, typename _H1, typename _H2, typename _Hash, typename _RehashPolicy,
bool __chc, bool __cit, bool __uk> bool __chc, bool __cit, bool __uk>
template<typename _Pair> template<typename _Arg>
typename _Hashtable<_Key, _Value, _Allocator, _ExtractKey, _Equal, typename _Hashtable<_Key, _Value, _Allocator, _ExtractKey, _Equal,
_H1, _H2, _Hash, _RehashPolicy, _H1, _H2, _Hash, _RehashPolicy,
__chc, __cit, __uk>::iterator __chc, __cit, __uk>::iterator
_Hashtable<_Key, _Value, _Allocator, _ExtractKey, _Equal, _Hashtable<_Key, _Value, _Allocator, _ExtractKey, _Equal,
_H1, _H2, _Hash, _RehashPolicy, __chc, __cit, __uk>:: _H1, _H2, _Hash, _RehashPolicy, __chc, __cit, __uk>::
_M_insert_bucket(_Pair&& __v, size_type __n, _M_insert_bucket(_Arg&& __v, size_type __n,
typename _Hashtable::_Hash_code_type __code) typename _Hashtable::_Hash_code_type __code)
{ {
std::pair<bool, std::size_t> __do_rehash std::pair<bool, std::size_t> __do_rehash
...@@ -919,7 +919,7 @@ namespace std ...@@ -919,7 +919,7 @@ namespace std
// Allocate the new node before doing the rehash so that we don't // Allocate the new node before doing the rehash so that we don't
// do a rehash if the allocation throws. // do a rehash if the allocation throws.
_Node* __new_node = _M_allocate_node(std::forward<_Pair>(__v)); _Node* __new_node = _M_allocate_node(std::forward<_Arg>(__v));
__try __try
{ {
...@@ -946,14 +946,14 @@ namespace std ...@@ -946,14 +946,14 @@ namespace std
typename _Allocator, typename _ExtractKey, typename _Equal, typename _Allocator, typename _ExtractKey, typename _Equal,
typename _H1, typename _H2, typename _Hash, typename _RehashPolicy, typename _H1, typename _H2, typename _Hash, typename _RehashPolicy,
bool __chc, bool __cit, bool __uk> bool __chc, bool __cit, bool __uk>
template<typename _Pair> template<typename _Arg>
std::pair<typename _Hashtable<_Key, _Value, _Allocator, std::pair<typename _Hashtable<_Key, _Value, _Allocator,
_ExtractKey, _Equal, _H1, _ExtractKey, _Equal, _H1,
_H2, _Hash, _RehashPolicy, _H2, _Hash, _RehashPolicy,
__chc, __cit, __uk>::iterator, bool> __chc, __cit, __uk>::iterator, bool>
_Hashtable<_Key, _Value, _Allocator, _ExtractKey, _Equal, _Hashtable<_Key, _Value, _Allocator, _ExtractKey, _Equal,
_H1, _H2, _Hash, _RehashPolicy, __chc, __cit, __uk>:: _H1, _H2, _Hash, _RehashPolicy, __chc, __cit, __uk>::
_M_insert(_Pair&& __v, std::true_type) _M_insert(_Arg&& __v, std::true_type)
{ {
const key_type& __k = this->_M_extract(__v); const key_type& __k = this->_M_extract(__v);
typename _Hashtable::_Hash_code_type __code = this->_M_hash_code(__k); typename _Hashtable::_Hash_code_type __code = this->_M_hash_code(__k);
...@@ -961,7 +961,7 @@ namespace std ...@@ -961,7 +961,7 @@ namespace std
if (_Node* __p = _M_find_node(_M_buckets[__n], __k, __code)) if (_Node* __p = _M_find_node(_M_buckets[__n], __k, __code))
return std::make_pair(iterator(__p, _M_buckets + __n), false); return std::make_pair(iterator(__p, _M_buckets + __n), false);
return std::make_pair(_M_insert_bucket(std::forward<_Pair>(__v), return std::make_pair(_M_insert_bucket(std::forward<_Arg>(__v),
__n, __code), true); __n, __code), true);
} }
...@@ -970,13 +970,13 @@ namespace std ...@@ -970,13 +970,13 @@ namespace std
typename _Allocator, typename _ExtractKey, typename _Equal, typename _Allocator, typename _ExtractKey, typename _Equal,
typename _H1, typename _H2, typename _Hash, typename _RehashPolicy, typename _H1, typename _H2, typename _Hash, typename _RehashPolicy,
bool __chc, bool __cit, bool __uk> bool __chc, bool __cit, bool __uk>
template<typename _Pair> template<typename _Arg>
typename _Hashtable<_Key, _Value, _Allocator, _ExtractKey, _Equal, typename _Hashtable<_Key, _Value, _Allocator, _ExtractKey, _Equal,
_H1, _H2, _Hash, _RehashPolicy, _H1, _H2, _Hash, _RehashPolicy,
__chc, __cit, __uk>::iterator __chc, __cit, __uk>::iterator
_Hashtable<_Key, _Value, _Allocator, _ExtractKey, _Equal, _Hashtable<_Key, _Value, _Allocator, _ExtractKey, _Equal,
_H1, _H2, _Hash, _RehashPolicy, __chc, __cit, __uk>:: _H1, _H2, _Hash, _RehashPolicy, __chc, __cit, __uk>::
_M_insert(_Pair&& __v, std::false_type) _M_insert(_Arg&& __v, std::false_type)
{ {
std::pair<bool, std::size_t> __do_rehash std::pair<bool, std::size_t> __do_rehash
= _M_rehash_policy._M_need_rehash(_M_bucket_count, = _M_rehash_policy._M_need_rehash(_M_bucket_count,
...@@ -990,7 +990,7 @@ namespace std ...@@ -990,7 +990,7 @@ namespace std
// First find the node, avoid leaking new_node if compare throws. // First find the node, avoid leaking new_node if compare throws.
_Node* __prev = _M_find_node(_M_buckets[__n], __k, __code); _Node* __prev = _M_find_node(_M_buckets[__n], __k, __code);
_Node* __new_node = _M_allocate_node(std::forward<_Pair>(__v)); _Node* __new_node = _M_allocate_node(std::forward<_Arg>(__v));
if (__prev) if (__prev)
{ {
......
...@@ -452,6 +452,21 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D) ...@@ -452,6 +452,21 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
return (*__i).second; return (*__i).second;
} }
#ifdef __GXX_EXPERIMENTAL_CXX0X__
mapped_type&
operator[](key_type&& __k)
{
// concept requirements
__glibcxx_function_requires(_DefaultConstructibleConcept<mapped_type>)
iterator __i = lower_bound(__k);
// __i->first is greater than or equivalent to __k.
if (__i == end() || key_comp()(__k, (*__i).first))
__i = insert(__i, std::make_pair(std::move(__k), mapped_type()));
return (*__i).second;
}
#endif
// _GLIBCXX_RESOLVE_LIB_DEFECTS // _GLIBCXX_RESOLVE_LIB_DEFECTS
// DR 464. Suggestion for new member functions in standard containers. // DR 464. Suggestion for new member functions in standard containers.
/** /**
...@@ -501,6 +516,15 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D) ...@@ -501,6 +516,15 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
{ return _M_t._M_insert_unique(__x); } { return _M_t._M_insert_unique(__x); }
#ifdef __GXX_EXPERIMENTAL_CXX0X__ #ifdef __GXX_EXPERIMENTAL_CXX0X__
template<typename _Pair, typename = typename
std::enable_if<std::is_convertible<_Pair,
value_type>::value>::type>
std::pair<iterator, bool>
insert(_Pair&& __x)
{ return _M_t._M_insert_unique(std::forward<_Pair>(__x)); }
#endif
#ifdef __GXX_EXPERIMENTAL_CXX0X__
/** /**
* @brief Attempts to insert a list of std::pairs into the %map. * @brief Attempts to insert a list of std::pairs into the %map.
* @param list A std::initializer_list<value_type> of pairs to be * @param list A std::initializer_list<value_type> of pairs to be
...@@ -544,6 +568,16 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D) ...@@ -544,6 +568,16 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
#endif #endif
{ return _M_t._M_insert_unique_(__position, __x); } { return _M_t._M_insert_unique_(__position, __x); }
#ifdef __GXX_EXPERIMENTAL_CXX0X__
template<typename _Pair, typename = typename
std::enable_if<std::is_convertible<_Pair,
value_type>::value>::type>
iterator
insert(const_iterator __position, _Pair&& __x)
{ return _M_t._M_insert_unique_(__position,
std::forward<_Pair>(__x)); }
#endif
/** /**
* @brief Template function that attempts to insert a range of elements. * @brief Template function that attempts to insert a range of elements.
* @param first Iterator pointing to the start of the range to be * @param first Iterator pointing to the start of the range to be
......
...@@ -438,6 +438,15 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D) ...@@ -438,6 +438,15 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
insert(const value_type& __x) insert(const value_type& __x)
{ return _M_t._M_insert_equal(__x); } { return _M_t._M_insert_equal(__x); }
#ifdef __GXX_EXPERIMENTAL_CXX0X__
template<typename _Pair, typename = typename
std::enable_if<std::is_convertible<_Pair,
value_type>::value>::type>
iterator
insert(_Pair&& __x)
{ return _M_t._M_insert_equal(std::forward<_Pair>(__x)); }
#endif
/** /**
* @brief Inserts a std::pair into the %multimap. * @brief Inserts a std::pair into the %multimap.
* @param position An iterator that serves as a hint as to where the * @param position An iterator that serves as a hint as to where the
...@@ -466,6 +475,16 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D) ...@@ -466,6 +475,16 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
#endif #endif
{ return _M_t._M_insert_equal_(__position, __x); } { return _M_t._M_insert_equal_(__position, __x); }
#ifdef __GXX_EXPERIMENTAL_CXX0X__
template<typename _Pair, typename = typename
std::enable_if<std::is_convertible<_Pair,
value_type>::value>::type>
iterator
insert(const_iterator __position, _Pair&& __x)
{ return _M_t._M_insert_equal_(__position,
std::forward<_Pair>(__x)); }
#endif
/** /**
* @brief A template function that attempts to insert a range * @brief A template function that attempts to insert a range
* of elements. * of elements.
......
...@@ -118,7 +118,7 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D) ...@@ -118,7 +118,7 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
typedef typename _Rep_type::const_iterator iterator; typedef typename _Rep_type::const_iterator iterator;
typedef typename _Rep_type::const_iterator const_iterator; typedef typename _Rep_type::const_iterator const_iterator;
typedef typename _Rep_type::const_reverse_iterator reverse_iterator; typedef typename _Rep_type::const_reverse_iterator reverse_iterator;
typedef typename _Rep_type::const_reverse_iterator const_reverse_iterator; typedef typename _Rep_type::const_reverse_iterator const_reverse_iterator;
typedef typename _Rep_type::size_type size_type; typedef typename _Rep_type::size_type size_type;
typedef typename _Rep_type::difference_type difference_type; typedef typename _Rep_type::difference_type difference_type;
...@@ -396,6 +396,12 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D) ...@@ -396,6 +396,12 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
insert(const value_type& __x) insert(const value_type& __x)
{ return _M_t._M_insert_equal(__x); } { return _M_t._M_insert_equal(__x); }
#ifdef __GXX_EXPERIMENTAL_CXX0X__
iterator
insert(value_type&& __x)
{ return _M_t._M_insert_equal(std::move(__x)); }
#endif
/** /**
* @brief Inserts an element into the %multiset. * @brief Inserts an element into the %multiset.
* @param position An iterator that serves as a hint as to where the * @param position An iterator that serves as a hint as to where the
...@@ -424,6 +430,12 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D) ...@@ -424,6 +430,12 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
#endif #endif
{ return _M_t._M_insert_equal_(__position, __x); } { return _M_t._M_insert_equal_(__position, __x); }
#ifdef __GXX_EXPERIMENTAL_CXX0X__
iterator
insert(const_iterator __position, value_type&& __x)
{ return _M_t._M_insert_equal_(__position, std::move(__x)); }
#endif
/** /**
* @brief A template function that tries to insert a range of elements. * @brief A template function that tries to insert a range of elements.
* @param first Iterator pointing to the start of the range to be * @param first Iterator pointing to the start of the range to be
......
...@@ -124,7 +124,7 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D) ...@@ -124,7 +124,7 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
typedef typename _Rep_type::const_iterator iterator; typedef typename _Rep_type::const_iterator iterator;
typedef typename _Rep_type::const_iterator const_iterator; typedef typename _Rep_type::const_iterator const_iterator;
typedef typename _Rep_type::const_reverse_iterator reverse_iterator; typedef typename _Rep_type::const_reverse_iterator reverse_iterator;
typedef typename _Rep_type::const_reverse_iterator const_reverse_iterator; typedef typename _Rep_type::const_reverse_iterator const_reverse_iterator;
typedef typename _Rep_type::size_type size_type; typedef typename _Rep_type::size_type size_type;
typedef typename _Rep_type::difference_type difference_type; typedef typename _Rep_type::difference_type difference_type;
//@} //@}
...@@ -409,6 +409,16 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D) ...@@ -409,6 +409,16 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
return std::pair<iterator, bool>(__p.first, __p.second); return std::pair<iterator, bool>(__p.first, __p.second);
} }
#ifdef __GXX_EXPERIMENTAL_CXX0X__
std::pair<iterator, bool>
insert(value_type&& __x)
{
std::pair<typename _Rep_type::iterator, bool> __p =
_M_t._M_insert_unique(std::move(__x));
return std::pair<iterator, bool>(__p.first, __p.second);
}
#endif
/** /**
* @brief Attempts to insert an element into the %set. * @brief Attempts to insert an element into the %set.
* @param position An iterator that serves as a hint as to where the * @param position An iterator that serves as a hint as to where the
...@@ -436,6 +446,12 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D) ...@@ -436,6 +446,12 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
#endif #endif
{ return _M_t._M_insert_unique_(__position, __x); } { return _M_t._M_insert_unique_(__position, __x); }
#ifdef __GXX_EXPERIMENTAL_CXX0X__
iterator
insert(const_iterator __position, value_type&& __x)
{ return _M_t._M_insert_unique_(__position, std::move(__x)); }
#endif
/** /**
* @brief A template function that attempts to insert a range * @brief A template function that attempts to insert a range
* of elements. * of elements.
......
...@@ -561,6 +561,19 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -561,6 +561,19 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
{ return iterator(static_cast<_Link_type> { return iterator(static_cast<_Link_type>
(const_cast<_Base_ptr>(__cit._M_node))); } (const_cast<_Base_ptr>(__cit._M_node))); }
#ifdef __GXX_EXPERIMENTAL_CXX0X__
template<typename _Arg>
iterator
_M_insert_(_Const_Base_ptr __x, _Const_Base_ptr __y, _Arg&& __v);
template<typename _Arg>
iterator
_M_insert_lower(_Base_ptr __x, _Base_ptr __y, _Arg&& __v);
template<typename _Arg>
iterator
_M_insert_equal_lower(_Arg&& __x);
#else
iterator iterator
_M_insert_(_Const_Base_ptr __x, _Const_Base_ptr __y, _M_insert_(_Const_Base_ptr __x, _Const_Base_ptr __y,
const value_type& __v); const value_type& __v);
...@@ -572,6 +585,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -572,6 +585,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
iterator iterator
_M_insert_equal_lower(const value_type& __x); _M_insert_equal_lower(const value_type& __x);
#endif
_Link_type _Link_type
_M_copy(_Const_Link_type __x, _Link_type __p); _M_copy(_Const_Link_type __x, _Link_type __p);
...@@ -687,6 +701,23 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -687,6 +701,23 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
swap(_Rb_tree& __t); swap(_Rb_tree& __t);
// Insert/erase. // Insert/erase.
#ifdef __GXX_EXPERIMENTAL_CXX0X__
template<typename _Arg>
pair<iterator, bool>
_M_insert_unique(_Arg&& __x);
template<typename _Arg>
iterator
_M_insert_equal(_Arg&& __x);
template<typename _Arg>
iterator
_M_insert_unique_(const_iterator __position, _Arg&& __x);
template<typename _Arg>
iterator
_M_insert_equal_(const_iterator __position, _Arg&& __x);
#else
pair<iterator, bool> pair<iterator, bool>
_M_insert_unique(const value_type& __x); _M_insert_unique(const value_type& __x);
...@@ -698,6 +729,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -698,6 +729,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
iterator iterator
_M_insert_equal_(const_iterator __position, const value_type& __x); _M_insert_equal_(const_iterator __position, const value_type& __x);
#endif
template<typename _InputIterator> template<typename _InputIterator>
void void
...@@ -901,15 +933,22 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -901,15 +933,22 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
template<typename _Key, typename _Val, typename _KeyOfValue, template<typename _Key, typename _Val, typename _KeyOfValue,
typename _Compare, typename _Alloc> typename _Compare, typename _Alloc>
#ifdef __GXX_EXPERIMENTAL_CXX0X__
template<typename _Arg>
#endif
typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator
_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
#ifdef __GXX_EXPERIMENTAL_CXX0X__
_M_insert_(_Const_Base_ptr __x, _Const_Base_ptr __p, _Arg&& __v)
#else
_M_insert_(_Const_Base_ptr __x, _Const_Base_ptr __p, const _Val& __v) _M_insert_(_Const_Base_ptr __x, _Const_Base_ptr __p, const _Val& __v)
#endif
{ {
bool __insert_left = (__x != 0 || __p == _M_end() bool __insert_left = (__x != 0 || __p == _M_end()
|| _M_impl._M_key_compare(_KeyOfValue()(__v), || _M_impl._M_key_compare(_KeyOfValue()(__v),
_S_key(__p))); _S_key(__p)));
_Link_type __z = _M_create_node(__v); _Link_type __z = _M_create_node(_GLIBCXX_FORWARD(_Arg, __v));
_Rb_tree_insert_and_rebalance(__insert_left, __z, _Rb_tree_insert_and_rebalance(__insert_left, __z,
const_cast<_Base_ptr>(__p), const_cast<_Base_ptr>(__p),
...@@ -920,15 +959,22 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -920,15 +959,22 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
template<typename _Key, typename _Val, typename _KeyOfValue, template<typename _Key, typename _Val, typename _KeyOfValue,
typename _Compare, typename _Alloc> typename _Compare, typename _Alloc>
#ifdef __GXX_EXPERIMENTAL_CXX0X__
template<typename _Arg>
#endif
typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator
_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
#ifdef __GXX_EXPERIMENTAL_CXX0X__
_M_insert_lower(_Base_ptr __x, _Base_ptr __p, _Arg&& __v)
#else
_M_insert_lower(_Base_ptr __x, _Base_ptr __p, const _Val& __v) _M_insert_lower(_Base_ptr __x, _Base_ptr __p, const _Val& __v)
#endif
{ {
bool __insert_left = (__x != 0 || __p == _M_end() bool __insert_left = (__x != 0 || __p == _M_end()
|| !_M_impl._M_key_compare(_S_key(__p), || !_M_impl._M_key_compare(_S_key(__p),
_KeyOfValue()(__v))); _KeyOfValue()(__v)));
_Link_type __z = _M_create_node(__v); _Link_type __z = _M_create_node(_GLIBCXX_FORWARD(_Arg, __v));
_Rb_tree_insert_and_rebalance(__insert_left, __z, __p, _Rb_tree_insert_and_rebalance(__insert_left, __z, __p,
this->_M_impl._M_header); this->_M_impl._M_header);
...@@ -938,9 +984,16 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -938,9 +984,16 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
template<typename _Key, typename _Val, typename _KeyOfValue, template<typename _Key, typename _Val, typename _KeyOfValue,
typename _Compare, typename _Alloc> typename _Compare, typename _Alloc>
#ifdef __GXX_EXPERIMENTAL_CXX0X__
template<typename _Arg>
#endif
typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator
_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
#ifdef __GXX_EXPERIMENTAL_CXX0X__
_M_insert_equal_lower(_Arg&& __v)
#else
_M_insert_equal_lower(const _Val& __v) _M_insert_equal_lower(const _Val& __v)
#endif
{ {
_Link_type __x = _M_begin(); _Link_type __x = _M_begin();
_Link_type __y = _M_end(); _Link_type __y = _M_end();
...@@ -950,7 +1003,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -950,7 +1003,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
__x = !_M_impl._M_key_compare(_S_key(__x), _KeyOfValue()(__v)) ? __x = !_M_impl._M_key_compare(_S_key(__x), _KeyOfValue()(__v)) ?
_S_left(__x) : _S_right(__x); _S_left(__x) : _S_right(__x);
} }
return _M_insert_lower(__x, __y, __v); return _M_insert_lower(__x, __y, _GLIBCXX_FORWARD(_Arg, __v));
} }
template<typename _Key, typename _Val, typename _KoV, template<typename _Key, typename _Val, typename _KoV,
...@@ -1183,10 +1236,17 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -1183,10 +1236,17 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
template<typename _Key, typename _Val, typename _KeyOfValue, template<typename _Key, typename _Val, typename _KeyOfValue,
typename _Compare, typename _Alloc> typename _Compare, typename _Alloc>
#ifdef __GXX_EXPERIMENTAL_CXX0X__
template<typename _Arg>
#endif
pair<typename _Rb_tree<_Key, _Val, _KeyOfValue, pair<typename _Rb_tree<_Key, _Val, _KeyOfValue,
_Compare, _Alloc>::iterator, bool> _Compare, _Alloc>::iterator, bool>
_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
#ifdef __GXX_EXPERIMENTAL_CXX0X__
_M_insert_unique(_Arg&& __v)
#else
_M_insert_unique(const _Val& __v) _M_insert_unique(const _Val& __v)
#endif
{ {
_Link_type __x = _M_begin(); _Link_type __x = _M_begin();
_Link_type __y = _M_end(); _Link_type __y = _M_end();
...@@ -1201,20 +1261,29 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -1201,20 +1261,29 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
if (__comp) if (__comp)
{ {
if (__j == begin()) if (__j == begin())
return pair<iterator, bool>(_M_insert_(__x, __y, __v), true); return pair<iterator, bool>
(_M_insert_(__x, __y, _GLIBCXX_FORWARD(_Arg, __v)), true);
else else
--__j; --__j;
} }
if (_M_impl._M_key_compare(_S_key(__j._M_node), _KeyOfValue()(__v))) if (_M_impl._M_key_compare(_S_key(__j._M_node), _KeyOfValue()(__v)))
return pair<iterator, bool>(_M_insert_(__x, __y, __v), true); return pair<iterator, bool>
(_M_insert_(__x, __y, _GLIBCXX_FORWARD(_Arg, __v)), true);
return pair<iterator, bool>(__j, false); return pair<iterator, bool>(__j, false);
} }
template<typename _Key, typename _Val, typename _KeyOfValue, template<typename _Key, typename _Val, typename _KeyOfValue,
typename _Compare, typename _Alloc> typename _Compare, typename _Alloc>
#ifdef __GXX_EXPERIMENTAL_CXX0X__
template<typename _Arg>
#endif
typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator
_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
#ifdef __GXX_EXPERIMENTAL_CXX0X__
_M_insert_equal(_Arg&& __v)
#else
_M_insert_equal(const _Val& __v) _M_insert_equal(const _Val& __v)
#endif
{ {
_Link_type __x = _M_begin(); _Link_type __x = _M_begin();
_Link_type __y = _M_end(); _Link_type __y = _M_end();
...@@ -1224,14 +1293,21 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -1224,14 +1293,21 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
__x = _M_impl._M_key_compare(_KeyOfValue()(__v), _S_key(__x)) ? __x = _M_impl._M_key_compare(_KeyOfValue()(__v), _S_key(__x)) ?
_S_left(__x) : _S_right(__x); _S_left(__x) : _S_right(__x);
} }
return _M_insert_(__x, __y, __v); return _M_insert_(__x, __y, _GLIBCXX_FORWARD(_Arg, __v));
} }
template<typename _Key, typename _Val, typename _KeyOfValue, template<typename _Key, typename _Val, typename _KeyOfValue,
typename _Compare, typename _Alloc> typename _Compare, typename _Alloc>
#ifdef __GXX_EXPERIMENTAL_CXX0X__
template<typename _Arg>
#endif
typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator
_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
#ifdef __GXX_EXPERIMENTAL_CXX0X__
_M_insert_unique_(const_iterator __position, _Arg&& __v)
#else
_M_insert_unique_(const_iterator __position, const _Val& __v) _M_insert_unique_(const_iterator __position, const _Val& __v)
#endif
{ {
// end() // end()
if (__position._M_node == _M_end()) if (__position._M_node == _M_end())
...@@ -1239,9 +1315,9 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -1239,9 +1315,9 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
if (size() > 0 if (size() > 0
&& _M_impl._M_key_compare(_S_key(_M_rightmost()), && _M_impl._M_key_compare(_S_key(_M_rightmost()),
_KeyOfValue()(__v))) _KeyOfValue()(__v)))
return _M_insert_(0, _M_rightmost(), __v); return _M_insert_(0, _M_rightmost(), _GLIBCXX_FORWARD(_Arg, __v));
else else
return _M_insert_unique(__v).first; return _M_insert_unique(_GLIBCXX_FORWARD(_Arg, __v)).first;
} }
else if (_M_impl._M_key_compare(_KeyOfValue()(__v), else if (_M_impl._M_key_compare(_KeyOfValue()(__v),
_S_key(__position._M_node))) _S_key(__position._M_node)))
...@@ -1249,18 +1325,21 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -1249,18 +1325,21 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
// First, try before... // First, try before...
const_iterator __before = __position; const_iterator __before = __position;
if (__position._M_node == _M_leftmost()) // begin() if (__position._M_node == _M_leftmost()) // begin()
return _M_insert_(_M_leftmost(), _M_leftmost(), __v); return _M_insert_(_M_leftmost(), _M_leftmost(),
_GLIBCXX_FORWARD(_Arg, __v));
else if (_M_impl._M_key_compare(_S_key((--__before)._M_node), else if (_M_impl._M_key_compare(_S_key((--__before)._M_node),
_KeyOfValue()(__v))) _KeyOfValue()(__v)))
{ {
if (_S_right(__before._M_node) == 0) if (_S_right(__before._M_node) == 0)
return _M_insert_(0, __before._M_node, __v); return _M_insert_(0, __before._M_node,
_GLIBCXX_FORWARD(_Arg, __v));
else else
return _M_insert_(__position._M_node, return _M_insert_(__position._M_node,
__position._M_node, __v); __position._M_node,
_GLIBCXX_FORWARD(_Arg, __v));
} }
else else
return _M_insert_unique(__v).first; return _M_insert_unique(_GLIBCXX_FORWARD(_Arg, __v)).first;
} }
else if (_M_impl._M_key_compare(_S_key(__position._M_node), else if (_M_impl._M_key_compare(_S_key(__position._M_node),
_KeyOfValue()(__v))) _KeyOfValue()(__v)))
...@@ -1268,17 +1347,20 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -1268,17 +1347,20 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
// ... then try after. // ... then try after.
const_iterator __after = __position; const_iterator __after = __position;
if (__position._M_node == _M_rightmost()) if (__position._M_node == _M_rightmost())
return _M_insert_(0, _M_rightmost(), __v); return _M_insert_(0, _M_rightmost(),
_GLIBCXX_FORWARD(_Arg, __v));
else if (_M_impl._M_key_compare(_KeyOfValue()(__v), else if (_M_impl._M_key_compare(_KeyOfValue()(__v),
_S_key((++__after)._M_node))) _S_key((++__after)._M_node)))
{ {
if (_S_right(__position._M_node) == 0) if (_S_right(__position._M_node) == 0)
return _M_insert_(0, __position._M_node, __v); return _M_insert_(0, __position._M_node,
_GLIBCXX_FORWARD(_Arg, __v));
else else
return _M_insert_(__after._M_node, __after._M_node, __v); return _M_insert_(__after._M_node, __after._M_node,
_GLIBCXX_FORWARD(_Arg, __v));
} }
else else
return _M_insert_unique(__v).first; return _M_insert_unique(_GLIBCXX_FORWARD(_Arg, __v)).first;
} }
else else
// Equivalent keys. // Equivalent keys.
...@@ -1287,9 +1369,16 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -1287,9 +1369,16 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
template<typename _Key, typename _Val, typename _KeyOfValue, template<typename _Key, typename _Val, typename _KeyOfValue,
typename _Compare, typename _Alloc> typename _Compare, typename _Alloc>
#ifdef __GXX_EXPERIMENTAL_CXX0X__
template<typename _Arg>
#endif
typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator
_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
#ifdef __GXX_EXPERIMENTAL_CXX0X__
_M_insert_equal_(const_iterator __position, _Arg&& __v)
#else
_M_insert_equal_(const_iterator __position, const _Val& __v) _M_insert_equal_(const_iterator __position, const _Val& __v)
#endif
{ {
// end() // end()
if (__position._M_node == _M_end()) if (__position._M_node == _M_end())
...@@ -1297,9 +1386,10 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -1297,9 +1386,10 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
if (size() > 0 if (size() > 0
&& !_M_impl._M_key_compare(_KeyOfValue()(__v), && !_M_impl._M_key_compare(_KeyOfValue()(__v),
_S_key(_M_rightmost()))) _S_key(_M_rightmost())))
return _M_insert_(0, _M_rightmost(), __v); return _M_insert_(0, _M_rightmost(),
_GLIBCXX_FORWARD(_Arg, __v));
else else
return _M_insert_equal(__v); return _M_insert_equal(_GLIBCXX_FORWARD(_Arg, __v));
} }
else if (!_M_impl._M_key_compare(_S_key(__position._M_node), else if (!_M_impl._M_key_compare(_S_key(__position._M_node),
_KeyOfValue()(__v))) _KeyOfValue()(__v)))
...@@ -1307,35 +1397,41 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -1307,35 +1397,41 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
// First, try before... // First, try before...
const_iterator __before = __position; const_iterator __before = __position;
if (__position._M_node == _M_leftmost()) // begin() if (__position._M_node == _M_leftmost()) // begin()
return _M_insert_(_M_leftmost(), _M_leftmost(), __v); return _M_insert_(_M_leftmost(), _M_leftmost(),
_GLIBCXX_FORWARD(_Arg, __v));
else if (!_M_impl._M_key_compare(_KeyOfValue()(__v), else if (!_M_impl._M_key_compare(_KeyOfValue()(__v),
_S_key((--__before)._M_node))) _S_key((--__before)._M_node)))
{ {
if (_S_right(__before._M_node) == 0) if (_S_right(__before._M_node) == 0)
return _M_insert_(0, __before._M_node, __v); return _M_insert_(0, __before._M_node,
_GLIBCXX_FORWARD(_Arg, __v));
else else
return _M_insert_(__position._M_node, return _M_insert_(__position._M_node,
__position._M_node, __v); __position._M_node,
_GLIBCXX_FORWARD(_Arg, __v));
} }
else else
return _M_insert_equal(__v); return _M_insert_equal(_GLIBCXX_FORWARD(_Arg, __v));
} }
else else
{ {
// ... then try after. // ... then try after.
const_iterator __after = __position; const_iterator __after = __position;
if (__position._M_node == _M_rightmost()) if (__position._M_node == _M_rightmost())
return _M_insert_(0, _M_rightmost(), __v); return _M_insert_(0, _M_rightmost(),
_GLIBCXX_FORWARD(_Arg, __v));
else if (!_M_impl._M_key_compare(_S_key((++__after)._M_node), else if (!_M_impl._M_key_compare(_S_key((++__after)._M_node),
_KeyOfValue()(__v))) _KeyOfValue()(__v)))
{ {
if (_S_right(__position._M_node) == 0) if (_S_right(__position._M_node) == 0)
return _M_insert_(0, __position._M_node, __v); return _M_insert_(0, __position._M_node,
_GLIBCXX_FORWARD(_Arg, __v));
else else
return _M_insert_(__after._M_node, __after._M_node, __v); return _M_insert_(__after._M_node, __after._M_node,
_GLIBCXX_FORWARD(_Arg, __v));
} }
else else
return _M_insert_equal_lower(__v); return _M_insert_equal_lower(_GLIBCXX_FORWARD(_Arg, __v));
} }
} }
......
...@@ -211,6 +211,21 @@ namespace __debug ...@@ -211,6 +211,21 @@ namespace __debug
} }
#ifdef __GXX_EXPERIMENTAL_CXX0X__ #ifdef __GXX_EXPERIMENTAL_CXX0X__
template<typename _Pair, typename = typename
std::enable_if<std::is_convertible<_Pair,
value_type>::value>::type>
std::pair<iterator, bool>
insert(_Pair&& __x)
{
typedef typename _Base::iterator _Base_iterator;
std::pair<_Base_iterator, bool> __res
= _Base::insert(std::forward<_Pair>(__x));
return std::pair<iterator, bool>(iterator(__res.first, this),
__res.second);
}
#endif
#ifdef __GXX_EXPERIMENTAL_CXX0X__
void void
insert(std::initializer_list<value_type> __list) insert(std::initializer_list<value_type> __list)
{ _Base::insert(__list); } { _Base::insert(__list); }
...@@ -223,6 +238,19 @@ namespace __debug ...@@ -223,6 +238,19 @@ namespace __debug
return iterator(_Base::insert(__position.base(), __x), this); return iterator(_Base::insert(__position.base(), __x), this);
} }
#ifdef __GXX_EXPERIMENTAL_CXX0X__
template<typename _Pair, typename = typename
std::enable_if<std::is_convertible<_Pair,
value_type>::value>::type>
iterator
insert(const_iterator __position, _Pair&& __x)
{
__glibcxx_check_insert(__position);
return iterator(_Base::insert(__position.base(),
std::forward<_Pair>(__x)), this);
}
#endif
template<typename _InputIterator> template<typename _InputIterator>
void void
insert(_InputIterator __first, _InputIterator __last) insert(_InputIterator __first, _InputIterator __last)
......
...@@ -198,6 +198,15 @@ namespace __debug ...@@ -198,6 +198,15 @@ namespace __debug
{ return iterator(_Base::insert(__x), this); } { return iterator(_Base::insert(__x), this); }
#ifdef __GXX_EXPERIMENTAL_CXX0X__ #ifdef __GXX_EXPERIMENTAL_CXX0X__
template<typename _Pair, typename = typename
std::enable_if<std::is_convertible<_Pair,
value_type>::value>::type>
iterator
insert(_Pair&& __x)
{ return iterator(_Base::insert(std::forward<_Pair>(__x)), this); }
#endif
#ifdef __GXX_EXPERIMENTAL_CXX0X__
void void
insert(std::initializer_list<value_type> __list) insert(std::initializer_list<value_type> __list)
{ _Base::insert(__list); } { _Base::insert(__list); }
...@@ -210,6 +219,19 @@ namespace __debug ...@@ -210,6 +219,19 @@ namespace __debug
return iterator(_Base::insert(__position.base(), __x), this); return iterator(_Base::insert(__position.base(), __x), this);
} }
#ifdef __GXX_EXPERIMENTAL_CXX0X__
template<typename _Pair, typename = typename
std::enable_if<std::is_convertible<_Pair,
value_type>::value>::type>
iterator
insert(const_iterator __position, _Pair&& __x)
{
__glibcxx_check_insert(__position);
return iterator(_Base::insert(__position.base(),
std::forward<_Pair>(__x)), this);
}
#endif
template<typename _InputIterator> template<typename _InputIterator>
void void
insert(_InputIterator __first, _InputIterator __last) insert(_InputIterator __first, _InputIterator __last)
......
...@@ -194,6 +194,12 @@ namespace __debug ...@@ -194,6 +194,12 @@ namespace __debug
insert(const value_type& __x) insert(const value_type& __x)
{ return iterator(_Base::insert(__x), this); } { return iterator(_Base::insert(__x), this); }
#ifdef __GXX_EXPERIMENTAL_CXX0X__
iterator
insert(value_type&& __x)
{ return iterator(_Base::insert(std::move(__x)), this); }
#endif
iterator iterator
insert(iterator __position, const value_type& __x) insert(iterator __position, const value_type& __x)
{ {
...@@ -201,6 +207,16 @@ namespace __debug ...@@ -201,6 +207,16 @@ namespace __debug
return iterator(_Base::insert(__position.base(), __x), this); return iterator(_Base::insert(__position.base(), __x), this);
} }
#ifdef __GXX_EXPERIMENTAL_CXX0X__
iterator
insert(const_iterator __position, value_type&& __x)
{
__glibcxx_check_insert(__position);
return iterator(_Base::insert(__position.base(), std::move(__x)),
this);
}
#endif
template<typename _InputIterator> template<typename _InputIterator>
void void
insert(_InputIterator __first, _InputIterator __last) insert(_InputIterator __first, _InputIterator __last)
......
...@@ -199,6 +199,18 @@ namespace __debug ...@@ -199,6 +199,18 @@ namespace __debug
__res.second); __res.second);
} }
#ifdef __GXX_EXPERIMENTAL_CXX0X__
std::pair<iterator, bool>
insert(value_type&& __x)
{
typedef typename _Base::iterator _Base_iterator;
std::pair<_Base_iterator, bool> __res
= _Base::insert(std::move(__x));
return std::pair<iterator, bool>(iterator(__res.first, this),
__res.second);
}
#endif
iterator iterator
insert(iterator __position, const value_type& __x) insert(iterator __position, const value_type& __x)
{ {
...@@ -206,6 +218,16 @@ namespace __debug ...@@ -206,6 +218,16 @@ namespace __debug
return iterator(_Base::insert(__position.base(), __x), this); return iterator(_Base::insert(__position.base(), __x), this);
} }
#ifdef __GXX_EXPERIMENTAL_CXX0X__
iterator
insert(const_iterator __position, value_type&& __x)
{
__glibcxx_check_insert(__position);
return iterator(_Base::insert(__position.base(), std::move(__x)),
this);
}
#endif
template <typename _InputIterator> template <typename _InputIterator>
void void
insert(_InputIterator __first, _InputIterator __last) insert(_InputIterator __first, _InputIterator __last)
......
...@@ -219,6 +219,15 @@ namespace __profile ...@@ -219,6 +219,15 @@ namespace __profile
return _Base::operator[](__k); return _Base::operator[](__k);
} }
#ifdef __GXX_EXPERIMENTAL_CXX0X__
mapped_type&
operator[](key_type&& __k)
{
__profcxx_map_to_unordered_map_find(this, size());
return _Base::operator[](std::move(__k));
}
#endif
mapped_type& mapped_type&
at(const key_type& __k) at(const key_type& __k)
{ {
...@@ -245,6 +254,22 @@ namespace __profile ...@@ -245,6 +254,22 @@ namespace __profile
} }
#ifdef __GXX_EXPERIMENTAL_CXX0X__ #ifdef __GXX_EXPERIMENTAL_CXX0X__
template<typename _Pair, typename = typename
std::enable_if<std::is_convertible<_Pair,
value_type>::value>::type>
std::pair<iterator, bool>
insert(_Pair&& __x)
{
__profcxx_map_to_unordered_map_insert(this, size(), 1);
typedef typename _Base::iterator _Base_iterator;
std::pair<_Base_iterator, bool> __res
= _Base::insert(std::forward<_Pair>(__x));
return std::pair<iterator, bool>(iterator(__res.first),
__res.second);
}
#endif
#ifdef __GXX_EXPERIMENTAL_CXX0X__
void void
insert(std::initializer_list<value_type> __list) insert(std::initializer_list<value_type> __list)
{ {
...@@ -269,6 +294,22 @@ namespace __profile ...@@ -269,6 +294,22 @@ namespace __profile
return __i; return __i;
} }
#ifdef __GXX_EXPERIMENTAL_CXX0X__
template<typename _Pair, typename = typename
std::enable_if<std::is_convertible<_Pair,
value_type>::value>::type>
iterator
insert(const_iterator __position, _Pair&& __x)
{
size_type size_before = size();
iterator __i
= iterator(_Base::insert(__position, std::forward<_Pair>(__x)));
__profcxx_map_to_unordered_map_insert(this, size_before,
size() - size_before);
return __i;
}
#endif
template<typename _InputIterator> template<typename _InputIterator>
void void
insert(_InputIterator __first, _InputIterator __last) insert(_InputIterator __first, _InputIterator __last)
......
...@@ -186,6 +186,15 @@ namespace __profile ...@@ -186,6 +186,15 @@ namespace __profile
{ return iterator(_Base::insert(__x)); } { return iterator(_Base::insert(__x)); }
#ifdef __GXX_EXPERIMENTAL_CXX0X__ #ifdef __GXX_EXPERIMENTAL_CXX0X__
template<typename _Pair, typename = typename
std::enable_if<std::is_convertible<_Pair,
value_type>::value>::type>
iterator
insert(_Pair&& __x)
{ return iterator(_Base::insert(std::forward<_Pair>(__x))); }
#endif
#ifdef __GXX_EXPERIMENTAL_CXX0X__
void void
insert(std::initializer_list<value_type> __list) insert(std::initializer_list<value_type> __list)
{ _Base::insert(__list); } { _Base::insert(__list); }
...@@ -199,6 +208,16 @@ namespace __profile ...@@ -199,6 +208,16 @@ namespace __profile
#endif #endif
{ return iterator(_Base::insert(__position, __x)); } { return iterator(_Base::insert(__position, __x)); }
#ifdef __GXX_EXPERIMENTAL_CXX0X__
template<typename _Pair, typename = typename
std::enable_if<std::is_convertible<_Pair,
value_type>::value>::type>
iterator
insert(const_iterator __position, _Pair&& __x)
{ return iterator(_Base::insert(__position,
std::forward<_Pair>(__x))); }
#endif
template<typename _InputIterator> template<typename _InputIterator>
void void
insert(_InputIterator __first, _InputIterator __last) insert(_InputIterator __first, _InputIterator __last)
......
...@@ -183,6 +183,12 @@ namespace __profile ...@@ -183,6 +183,12 @@ namespace __profile
insert(const value_type& __x) insert(const value_type& __x)
{ return iterator(_Base::insert(__x)); } { return iterator(_Base::insert(__x)); }
#ifdef __GXX_EXPERIMENTAL_CXX0X__
iterator
insert(value_type&& __x)
{ return iterator(_Base::insert(std::move(__x))); }
#endif
iterator iterator
#ifdef __GXX_EXPERIMENTAL_CXX0X__ #ifdef __GXX_EXPERIMENTAL_CXX0X__
insert(const_iterator __position, const value_type& __x) insert(const_iterator __position, const value_type& __x)
...@@ -191,6 +197,12 @@ namespace __profile ...@@ -191,6 +197,12 @@ namespace __profile
#endif #endif
{ return iterator(_Base::insert(__position, __x)); } { return iterator(_Base::insert(__position, __x)); }
#ifdef __GXX_EXPERIMENTAL_CXX0X__
iterator
insert(const_iterator __position, value_type&& __x)
{ return iterator(_Base::insert(__position, std::move(__x))); }
#endif
template<typename _InputIterator> template<typename _InputIterator>
void void
insert(_InputIterator __first, _InputIterator __last) insert(_InputIterator __first, _InputIterator __last)
......
...@@ -188,6 +188,18 @@ namespace __profile ...@@ -188,6 +188,18 @@ namespace __profile
__res.second); __res.second);
} }
#ifdef __GXX_EXPERIMENTAL_CXX0X__
std::pair<iterator, bool>
insert(value_type&& __x)
{
typedef typename _Base::iterator _Base_iterator;
std::pair<_Base_iterator, bool> __res
= _Base::insert(std::move(__x));
return std::pair<iterator, bool>(iterator(__res.first),
__res.second);
}
#endif
iterator iterator
#ifdef __GXX_EXPERIMENTAL_CXX0X__ #ifdef __GXX_EXPERIMENTAL_CXX0X__
insert(const_iterator __position, const value_type& __x) insert(const_iterator __position, const value_type& __x)
...@@ -196,6 +208,12 @@ namespace __profile ...@@ -196,6 +208,12 @@ namespace __profile
#endif #endif
{ return iterator(_Base::insert(__position, __x)); } { return iterator(_Base::insert(__position, __x)); }
#ifdef __GXX_EXPERIMENTAL_CXX0X__
iterator
insert(const_iterator __position, value_type&& __x)
{ return iterator(_Base::insert(__position, std::move(__x))); }
#endif
template <typename _InputIterator> template <typename _InputIterator>
void void
insert(_InputIterator __first, _InputIterator __last) insert(_InputIterator __first, _InputIterator __last)
......
// { dg-options "-std=gnu++0x" }
// 2010-11-10 Paolo Carlini <paolo.carlini@oracle.com>
//
// Copyright (C) 2010 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
#include <iterator>
#include <map>
#include <testsuite_hooks.h>
#include <testsuite_rvalref.h>
void test01()
{
bool test __attribute__((unused)) = true;
using __gnu_test::rvalstruct;
typedef std::map<rvalstruct, rvalstruct> Map;
Map m;
VERIFY( m.empty() );
m[rvalstruct(1)] = rvalstruct(17);
VERIFY( m.size() == 1 );
VERIFY( (m.begin()->first).val == 1 );
VERIFY( (m.begin()->second).val == 17 );
VERIFY( m[rvalstruct(1)].val == 17 );
m[rvalstruct(2)] = rvalstruct(9);
VERIFY( m.size() == 2 );
VERIFY( m[rvalstruct(2)].val == 9 );
m[rvalstruct(1)] = rvalstruct(5);
VERIFY( m.size() == 2 );
VERIFY( m[rvalstruct(1)].val == 5 );
VERIFY( m[rvalstruct(2)].val == 9 );
}
int main()
{
test01();
return 0;
}
// { dg-options "-std=gnu++0x" }
// Copyright (C) 2010 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
#include <map>
class moveable
{
public:
moveable(moveable&&) { }
moveable() { }
operator int()
{ return 0; }
};
// libstdc++/46148
int main()
{
std::map<bool,moveable> the_map;
return the_map[true];
}
// { dg-options "-std=gnu++0x" }
// 2010-11-10 Paolo Carlini <paolo.carlini@oracle.com>
//
// Copyright (C) 2010 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
#include <iterator>
#include <map>
#include <testsuite_hooks.h>
#include <testsuite_rvalref.h>
void test01()
{
bool test __attribute__((unused)) = true;
using __gnu_test::rvalstruct;
typedef std::map<int, rvalstruct> Map;
typedef std::pair<const int, rvalstruct> Pair;
Map m;
VERIFY( m.empty());
std::pair<Map::iterator, bool> p = m.insert(Pair(1, rvalstruct(3)));
VERIFY( p.second );
VERIFY( m.size() == 1 );
VERIFY( std::distance(m.begin(), m.end()) == 1 );
VERIFY( p.first == m.begin() );
VERIFY( p.first->first == 1 );
VERIFY( (p.first->second).val == 3 );
}
void test02()
{
bool test __attribute__((unused)) = true;
using __gnu_test::rvalstruct;
typedef std::map<int, rvalstruct> Map;
typedef std::pair<const int, rvalstruct> Pair;
Map m;
VERIFY( m.empty() );
std::pair<Map::iterator, bool> p1 = m.insert(Pair(2, rvalstruct(3)));
std::pair<Map::iterator, bool> p2 = m.insert(Pair(2, rvalstruct(7)));
VERIFY( p1.second );
VERIFY( !p2.second );
VERIFY( m.size() == 1 );
VERIFY( p1.first == p2.first );
VERIFY( p1.first->first == 2 );
VERIFY( (p2.first->second).val == 3 );
}
int main()
{
test01();
test02();
return 0;
}
// { dg-options "-std=gnu++0x" }
// 2010-11-10 Paolo Carlini <paolo.carlini@oracle.com>
//
// Copyright (C) 2010 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
#include <iterator>
#include <map>
#include <testsuite_hooks.h>
#include <testsuite_rvalref.h>
void test01()
{
bool test __attribute__((unused)) = true;
using __gnu_test::rvalstruct;
typedef std::map<rvalstruct, rvalstruct> Map;
typedef std::pair<rvalstruct, rvalstruct> Pair;
Map m;
VERIFY( m.empty());
std::pair<Map::iterator, bool> p = m.insert(Pair(rvalstruct(1),
rvalstruct(3)));
VERIFY( p.second );
VERIFY( m.size() == 1 );
VERIFY( std::distance(m.begin(), m.end()) == 1 );
VERIFY( p.first == m.begin() );
VERIFY( (p.first->first).val == 1 );
VERIFY( (p.first->second).val == 3 );
}
void test02()
{
bool test __attribute__((unused)) = true;
using __gnu_test::rvalstruct;
typedef std::map<rvalstruct, rvalstruct> Map;
typedef std::pair<rvalstruct, rvalstruct> Pair;
Map m;
VERIFY( m.empty() );
std::pair<Map::iterator, bool> p1 = m.insert(Pair(rvalstruct(2),
rvalstruct(3)));
std::pair<Map::iterator, bool> p2 = m.insert(Pair(rvalstruct(2),
rvalstruct(7)));
VERIFY( p1.second );
VERIFY( !p2.second );
VERIFY( m.size() == 1 );
VERIFY( p1.first == p2.first );
VERIFY( (p1.first->first).val == 2 );
VERIFY( (p2.first->second).val == 3 );
}
int main()
{
test01();
test02();
return 0;
}
// { dg-options "-std=gnu++0x" }
// 2010-11-10 Paolo Carlini <paolo.carlini@oracle.com>
//
// Copyright (C) 2010 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
#include <iterator>
#include <map>
#include <testsuite_hooks.h>
#include <testsuite_rvalref.h>
void test01()
{
bool test __attribute__((unused)) = true;
using __gnu_test::rvalstruct;
typedef std::map<int, rvalstruct> Map;
typedef std::pair<const int, rvalstruct> Pair;
Map m;
VERIFY( m.empty());
Map::iterator p = m.insert(m.begin(), Pair(1, rvalstruct(3)));
VERIFY( m.size() == 1 );
VERIFY( std::distance(m.begin(), m.end()) == 1 );
VERIFY( p == m.begin() );
VERIFY( p->first == 1 );
VERIFY( (p->second).val == 3 );
}
void test02()
{
bool test __attribute__((unused)) = true;
using __gnu_test::rvalstruct;
typedef std::map<int, rvalstruct> Map;
typedef std::pair<const int, rvalstruct> Pair;
Map m;
VERIFY( m.empty() );
Map::iterator p1 = m.insert(m.begin(), Pair(2, rvalstruct(3)));
Map::iterator p2 = m.insert(p1, Pair(2, rvalstruct(7)));
VERIFY( m.size() == 1 );
VERIFY( p1 == p2 );
VERIFY( p1->first == 2 );
VERIFY( (p2->second).val == 3 );
}
int main()
{
test01();
test02();
return 0;
}
// { dg-options "-std=gnu++0x" }
// 2010-11-10 Paolo Carlini <paolo.carlini@oracle.com>
//
// Copyright (C) 2010 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
#include <iterator>
#include <map>
#include <testsuite_hooks.h>
#include <testsuite_rvalref.h>
void test01()
{
bool test __attribute__((unused)) = true;
using __gnu_test::rvalstruct;
typedef std::map<rvalstruct, rvalstruct> Map;
typedef std::pair<rvalstruct, rvalstruct> Pair;
Map m;
VERIFY( m.empty());
Map::iterator p = m.insert(m.begin(), Pair(rvalstruct(1),
rvalstruct(3)));
VERIFY( m.size() == 1 );
VERIFY( std::distance(m.begin(), m.end()) == 1 );
VERIFY( p == m.begin() );
VERIFY( (p->first).val == 1 );
VERIFY( (p->second).val == 3 );
}
void test02()
{
bool test __attribute__((unused)) = true;
using __gnu_test::rvalstruct;
typedef std::map<rvalstruct, rvalstruct> Map;
typedef std::pair<rvalstruct, rvalstruct> Pair;
Map m;
VERIFY( m.empty() );
Map::iterator p1 = m.insert(m.begin(), Pair(rvalstruct(2),
rvalstruct(3)));
Map::iterator p2 = m.insert(p1, Pair(rvalstruct(2),
rvalstruct(7)));
VERIFY( m.size() == 1 );
VERIFY( p1 == p2 );
VERIFY( (p1->first).val == 2 );
VERIFY( (p2->second).val == 3 );
}
int main()
{
test01();
test02();
return 0;
}
// { dg-options "-std=gnu++0x" }
// 2010-11-10 Paolo Carlini <paolo.carlini@oracle.com>
//
// Copyright (C) 2010 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
#include <iterator>
#include <map>
#include <testsuite_hooks.h>
#include <testsuite_rvalref.h>
void test01()
{
bool test __attribute__((unused)) = true;
using __gnu_test::rvalstruct;
typedef std::multimap<int, rvalstruct> Map;
typedef std::pair<const int, rvalstruct> Pair;
Map m;
VERIFY( m.empty() );
Map::iterator i = m.insert(Pair(1, rvalstruct(3)));
VERIFY( m.size() == 1 );
VERIFY( std::distance(m.begin(), m.end()) == 1 );
VERIFY( i == m.begin() );
VERIFY( i->first == 1 );
VERIFY( (i->second).val == 3 );
}
void test02()
{
bool test __attribute__((unused)) = true;
using __gnu_test::rvalstruct;
typedef std::multimap<int, rvalstruct> Map;
typedef std::pair<const int, rvalstruct> Pair;
Map m;
VERIFY( m.empty() );
m.insert(Pair(2, rvalstruct(3)));
m.insert(Pair(2, rvalstruct(7)));
VERIFY( m.size() == 2 );
VERIFY( std::distance(m.begin(), m.end()) == 2 );
Map::iterator i1 = m.begin();
Map::iterator i2 = i1;
++i2;
VERIFY( i1->first == 2 );
VERIFY( i2->first == 2 );
VERIFY( (i1->second).val == 3 && (i2->second).val == 7 );
}
int main()
{
test01();
test02();
return 0;
}
// { dg-options "-std=gnu++0x" }
// 2010-11-10 Paolo Carlini <paolo.carlini@oracle.com>
//
// Copyright (C) 2010 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
#include <iterator>
#include <map>
#include <testsuite_hooks.h>
#include <testsuite_rvalref.h>
void test01()
{
bool test __attribute__((unused)) = true;
using __gnu_test::rvalstruct;
typedef std::multimap<rvalstruct, rvalstruct> Map;
typedef std::pair<rvalstruct, rvalstruct> Pair;
Map m;
VERIFY( m.empty() );
Map::iterator i = m.insert(Pair(rvalstruct(1), rvalstruct(3)));
VERIFY( m.size() == 1 );
VERIFY( std::distance(m.begin(), m.end()) == 1 );
VERIFY( i == m.begin() );
VERIFY( (i->first).val == 1 );
VERIFY( (i->second).val == 3 );
}
void test02()
{
bool test __attribute__((unused)) = true;
using __gnu_test::rvalstruct;
typedef std::multimap<rvalstruct, rvalstruct> Map;
typedef std::pair<rvalstruct, rvalstruct> Pair;
Map m;
VERIFY( m.empty() );
m.insert(Pair(rvalstruct(2), rvalstruct(3)));
m.insert(Pair(rvalstruct(2), rvalstruct(7)));
VERIFY( m.size() == 2 );
VERIFY( std::distance(m.begin(), m.end()) == 2 );
Map::iterator i1 = m.begin();
Map::iterator i2 = i1;
++i2;
VERIFY( (i1->first).val == 2 );
VERIFY( (i2->first).val == 2 );
VERIFY( (i1->second).val == 3 && (i2->second).val == 7 );
}
int main()
{
test01();
test02();
return 0;
}
// { dg-options "-std=gnu++0x" }
// 2010-11-10 Paolo Carlini <paolo.carlini@oracle.com>
//
// Copyright (C) 2010 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
#include <iterator>
#include <map>
#include <testsuite_hooks.h>
#include <testsuite_rvalref.h>
void test01()
{
bool test __attribute__((unused)) = true;
using __gnu_test::rvalstruct;
typedef std::multimap<int, rvalstruct> Map;
typedef std::pair<const int, rvalstruct> Pair;
Map m;
VERIFY( m.empty() );
Map::iterator i = m.insert(m.begin(), Pair(1, rvalstruct(3)));
VERIFY( m.size() == 1 );
VERIFY( std::distance(m.begin(), m.end()) == 1 );
VERIFY( i == m.begin() );
VERIFY( i->first == 1 );
VERIFY( (i->second).val == 3 );
}
void test02()
{
bool test __attribute__((unused)) = true;
using __gnu_test::rvalstruct;
typedef std::multimap<int, rvalstruct> Map;
typedef std::pair<const int, rvalstruct> Pair;
Map m;
VERIFY( m.empty() );
Map::iterator i0 = m.insert(m.begin(), Pair(2, rvalstruct(3)));
m.insert(i0, Pair(2, rvalstruct(7)));
VERIFY( m.size() == 2 );
VERIFY( std::distance(m.begin(), m.end()) == 2 );
Map::iterator i1 = m.begin();
Map::iterator i2 = i1;
++i2;
VERIFY( i1->first == 2 );
VERIFY( i2->first == 2 );
VERIFY( (i1->second).val == 7 && (i2->second).val == 3 );
}
int main()
{
test01();
test02();
return 0;
}
// { dg-options "-std=gnu++0x" }
// 2010-11-10 Paolo Carlini <paolo.carlini@oracle.com>
//
// Copyright (C) 2010 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
#include <iterator>
#include <map>
#include <testsuite_hooks.h>
#include <testsuite_rvalref.h>
void test01()
{
bool test __attribute__((unused)) = true;
using __gnu_test::rvalstruct;
typedef std::multimap<rvalstruct, rvalstruct> Map;
typedef std::pair<rvalstruct, rvalstruct> Pair;
Map m;
VERIFY( m.empty() );
Map::iterator i = m.insert(m.begin(),
Pair(rvalstruct(1), rvalstruct(3)));
VERIFY( m.size() == 1 );
VERIFY( std::distance(m.begin(), m.end()) == 1 );
VERIFY( i == m.begin() );
VERIFY( (i->first).val == 1 );
VERIFY( (i->second).val == 3 );
}
void test02()
{
bool test __attribute__((unused)) = true;
using __gnu_test::rvalstruct;
typedef std::multimap<rvalstruct, rvalstruct> Map;
typedef std::pair<rvalstruct, rvalstruct> Pair;
Map m;
VERIFY( m.empty() );
Map::iterator i0 = m.insert(Pair(rvalstruct(2), rvalstruct(3)));
m.insert(i0, Pair(rvalstruct(2), rvalstruct(7)));
VERIFY( m.size() == 2 );
VERIFY( std::distance(m.begin(), m.end()) == 2 );
Map::iterator i1 = m.begin();
Map::iterator i2 = i1;
++i2;
VERIFY( (i1->first).val == 2 );
VERIFY( (i2->first).val == 2 );
VERIFY( (i1->second).val == 7 && (i2->second).val == 3 );
}
int main()
{
test01();
test02();
return 0;
}
// { dg-options "-std=gnu++0x" }
// 2010-11-10 Paolo Carlini <paolo.carlini@oracle.com>
//
// Copyright (C) 2010 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
#include <iterator>
#include <set>
#include <testsuite_hooks.h>
#include <testsuite_rvalref.h>
void test01()
{
bool test __attribute__((unused)) = true;
using __gnu_test::rvalstruct;
typedef std::multiset<rvalstruct> Set;
Set s;
VERIFY( s.empty() );
Set::iterator i = s.insert(rvalstruct(1));
VERIFY( s.size() == 1 );
VERIFY( std::distance(s.begin(), s.end()) == 1 );
VERIFY( i == s.begin() );
VERIFY( (*i).val == 1 );
}
void test02()
{
bool test __attribute__((unused)) = true;
using __gnu_test::rvalstruct;
typedef std::multiset<rvalstruct> Set;
Set s;
VERIFY( s.empty() );
s.insert(rvalstruct(2));
Set::iterator i = s.insert(rvalstruct(2));
VERIFY( s.size() == 2 );
VERIFY( std::distance(s.begin(), s.end()) == 2 );
VERIFY( (*i).val == 2 );
Set::iterator i2 = s.begin();
++i2;
VERIFY( i == s.begin() || i == i2 );
VERIFY( (*(s.begin())).val == 2 && (*i2).val == 2 );
}
int main()
{
test01();
test02();
return 0;
}
// { dg-options "-std=gnu++0x" }
// 2010-11-10 Paolo Carlini <paolo.carlini@oracle.com>
//
// Copyright (C) 2010 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
#include <iterator>
#include <set>
#include <testsuite_hooks.h>
#include <testsuite_rvalref.h>
void test01()
{
bool test __attribute__((unused)) = true;
using __gnu_test::rvalstruct;
typedef std::multiset<rvalstruct> Set;
Set s;
VERIFY( s.empty() );
Set::iterator i = s.insert(s.begin(), rvalstruct(1));
VERIFY( s.size() == 1 );
VERIFY( std::distance(s.begin(), s.end()) == 1 );
VERIFY( i == s.begin() );
VERIFY( (*i).val == 1 );
}
void test02()
{
bool test __attribute__((unused)) = true;
using __gnu_test::rvalstruct;
typedef std::multiset<rvalstruct> Set;
Set s;
VERIFY( s.empty() );
Set::iterator i0 = s.insert(s.begin(), rvalstruct(2));
Set::iterator i1 = s.insert(i0, rvalstruct(2));
VERIFY( s.size() == 2 );
VERIFY( std::distance(s.begin(), s.end()) == 2 );
VERIFY( (*i1).val == 2 );
Set::iterator i2 = s.begin();
++i2;
VERIFY( i1 == s.begin() );
VERIFY( (*(s.begin())).val == 2 && (*i2).val == 2 );
}
int main()
{
test01();
test02();
return 0;
}
// { dg-options "-std=gnu++0x" }
// 2010-11-10 Paolo Carlini <paolo.carlini@oracle.com>
//
// Copyright (C) 2010 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
#include <iterator>
#include <set>
#include <testsuite_hooks.h>
#include <testsuite_rvalref.h>
void test01()
{
bool test __attribute__((unused)) = true;
using __gnu_test::rvalstruct;
typedef std::set<rvalstruct> Set;
Set s;
VERIFY( s.empty() );
std::pair<Set::iterator, bool> p = s.insert(rvalstruct(1));
VERIFY( p.second );
VERIFY( s.size() == 1 );
VERIFY( std::distance(s.begin(), s.end()) == 1 );
VERIFY( p.first == s.begin() );
VERIFY( (*p.first).val == 1 );
}
void test02()
{
bool test __attribute__((unused)) = true;
using __gnu_test::rvalstruct;
typedef std::set<rvalstruct> Set;
Set s;
VERIFY( s.empty() );
std::pair<Set::iterator, bool> p1 = s.insert(rvalstruct(2));
std::pair<Set::iterator, bool> p2 = s.insert(rvalstruct(2));
VERIFY( p1.second );
VERIFY( !p2.second );
VERIFY( s.size() == 1 );
VERIFY( p1.first == p2.first );
VERIFY( (*p1.first).val == 2 );
}
int main()
{
test01();
test02();
return 0;
}
// { dg-options "-std=gnu++0x" }
// 2010-11-10 Paolo Carlini <paolo.carlini@oracle.com>
//
// Copyright (C) 2010 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
#include <iterator>
#include <set>
#include <testsuite_hooks.h>
#include <testsuite_rvalref.h>
void test01()
{
bool test __attribute__((unused)) = true;
using __gnu_test::rvalstruct;
typedef std::set<rvalstruct> Set;
Set s;
VERIFY( s.empty() );
Set::iterator p = s.insert(s.begin(), rvalstruct(1));
VERIFY( s.size() == 1 );
VERIFY( std::distance(s.begin(), s.end()) == 1 );
VERIFY( p == s.begin() );
VERIFY( (*p).val == 1 );
}
void test02()
{
bool test __attribute__((unused)) = true;
using __gnu_test::rvalstruct;
typedef std::set<rvalstruct> Set;
Set s;
VERIFY( s.empty() );
Set::iterator p1 = s.insert(s.begin(), rvalstruct(2));
Set::iterator p2 = s.insert(p1, rvalstruct(2));
VERIFY( s.size() == 1 );
VERIFY( p1 == p2 );
VERIFY( (*p1).val == 2 );
}
int main()
{
test01();
test02();
return 0;
}
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