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,
_Hashtable<>::_Insert_Return_Type): Change to private.
_M_find_node(_Node*, const key_type&,
typename _Hashtable::_Hash_code_type) const;
- template<typename _Pair>
+ template<typename _Arg>
iterator
- _M_insert_bucket(_Pair&&, size_type,
+ _M_insert_bucket(_Arg&&, size_type,
typename _Hashtable::_Hash_code_type);
- template<typename _Pair>
+ template<typename _Arg>
std::pair<iterator, bool>
- _M_insert(_Pair&&, std::true_type);
+ _M_insert(_Arg&&, std::true_type);
- template<typename _Pair>
+ template<typename _Arg>
iterator
- _M_insert(_Pair&&, std::false_type);
+ _M_insert(_Arg&&, std::false_type);
typedef typename std::conditional<__unique_keys,
std::pair<iterator, bool>,
typename _Allocator, typename _ExtractKey, typename _Equal,
typename _H1, typename _H2, typename _Hash, typename _RehashPolicy,
bool __chc, bool __cit, bool __uk>
- template<typename _Pair>
+ template<typename _Arg>
typename _Hashtable<_Key, _Value, _Allocator, _ExtractKey, _Equal,
_H1, _H2, _Hash, _RehashPolicy,
__chc, __cit, __uk>::iterator
_Hashtable<_Key, _Value, _Allocator, _ExtractKey, _Equal,
_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)
{
std::pair<bool, std::size_t> __do_rehash
// Allocate the new node before doing the rehash so that we don't
// 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
{
typename _Allocator, typename _ExtractKey, typename _Equal,
typename _H1, typename _H2, typename _Hash, typename _RehashPolicy,
bool __chc, bool __cit, bool __uk>
- template<typename _Pair>
+ template<typename _Arg>
std::pair<typename _Hashtable<_Key, _Value, _Allocator,
_ExtractKey, _Equal, _H1,
_H2, _Hash, _RehashPolicy,
__chc, __cit, __uk>::iterator, bool>
_Hashtable<_Key, _Value, _Allocator, _ExtractKey, _Equal,
_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);
typename _Hashtable::_Hash_code_type __code = this->_M_hash_code(__k);
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(_M_insert_bucket(std::forward<_Pair>(__v),
+ return std::make_pair(_M_insert_bucket(std::forward<_Arg>(__v),
__n, __code), true);
}
typename _Allocator, typename _ExtractKey, typename _Equal,
typename _H1, typename _H2, typename _Hash, typename _RehashPolicy,
bool __chc, bool __cit, bool __uk>
- template<typename _Pair>
+ template<typename _Arg>
typename _Hashtable<_Key, _Value, _Allocator, _ExtractKey, _Equal,
_H1, _H2, _Hash, _RehashPolicy,
__chc, __cit, __uk>::iterator
_Hashtable<_Key, _Value, _Allocator, _ExtractKey, _Equal,
_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
= _M_rehash_policy._M_need_rehash(_M_bucket_count,
// First find the node, avoid leaking new_node if compare throws.
_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)
{
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
// DR 464. Suggestion for new member functions in standard containers.
/**
{ return _M_t._M_insert_unique(__x); }
#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.
* @param list A std::initializer_list<value_type> of pairs to be
#endif
{ 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.
* @param first Iterator pointing to the start of the range to be
insert(const value_type& __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.
* @param position An iterator that serves as a hint as to where the
#endif
{ 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
* of elements.
typedef typename _Rep_type::const_iterator 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 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::difference_type difference_type;
insert(const value_type& __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.
* @param position An iterator that serves as a hint as to where the
#endif
{ 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.
* @param first Iterator pointing to the start of the range to be
typedef typename _Rep_type::const_iterator 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 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::difference_type difference_type;
//@}
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.
* @param position An iterator that serves as a hint as to where the
#endif
{ 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
* of elements.
{ return iterator(static_cast<_Link_type>
(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
_M_insert_(_Const_Base_ptr __x, _Const_Base_ptr __y,
const value_type& __v);
iterator
_M_insert_equal_lower(const value_type& __x);
+#endif
_Link_type
_M_copy(_Const_Link_type __x, _Link_type __p);
swap(_Rb_tree& __t);
// 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>
_M_insert_unique(const value_type& __x);
iterator
_M_insert_equal_(const_iterator __position, const value_type& __x);
+#endif
template<typename _InputIterator>
void
template<typename _Key, typename _Val, typename _KeyOfValue,
typename _Compare, typename _Alloc>
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+ template<typename _Arg>
+#endif
typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator
_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)
+#endif
{
bool __insert_left = (__x != 0 || __p == _M_end()
|| _M_impl._M_key_compare(_KeyOfValue()(__v),
_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,
const_cast<_Base_ptr>(__p),
template<typename _Key, typename _Val, typename _KeyOfValue,
typename _Compare, typename _Alloc>
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+ template<typename _Arg>
+#endif
typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator
_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)
+#endif
{
bool __insert_left = (__x != 0 || __p == _M_end()
|| !_M_impl._M_key_compare(_S_key(__p),
_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,
this->_M_impl._M_header);
template<typename _Key, typename _Val, typename _KeyOfValue,
typename _Compare, typename _Alloc>
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+ template<typename _Arg>
+#endif
typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator
_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)
+#endif
{
_Link_type __x = _M_begin();
_Link_type __y = _M_end();
__x = !_M_impl._M_key_compare(_S_key(__x), _KeyOfValue()(__v)) ?
_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 _KeyOfValue,
typename _Compare, typename _Alloc>
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+ template<typename _Arg>
+#endif
pair<typename _Rb_tree<_Key, _Val, _KeyOfValue,
_Compare, _Alloc>::iterator, bool>
_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+ _M_insert_unique(_Arg&& __v)
+#else
_M_insert_unique(const _Val& __v)
+#endif
{
_Link_type __x = _M_begin();
_Link_type __y = _M_end();
if (__comp)
{
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
--__j;
}
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);
}
template<typename _Key, typename _Val, typename _KeyOfValue,
typename _Compare, typename _Alloc>
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+ template<typename _Arg>
+#endif
typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator
_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+ _M_insert_equal(_Arg&& __v)
+#else
_M_insert_equal(const _Val& __v)
+#endif
{
_Link_type __x = _M_begin();
_Link_type __y = _M_end();
__x = _M_impl._M_key_compare(_KeyOfValue()(__v), _S_key(__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,
typename _Compare, typename _Alloc>
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+ template<typename _Arg>
+#endif
typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator
_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)
+#endif
{
// end()
if (__position._M_node == _M_end())
if (size() > 0
&& _M_impl._M_key_compare(_S_key(_M_rightmost()),
_KeyOfValue()(__v)))
- return _M_insert_(0, _M_rightmost(), __v);
+ return _M_insert_(0, _M_rightmost(), _GLIBCXX_FORWARD(_Arg, __v));
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),
_S_key(__position._M_node)))
// First, try before...
const_iterator __before = __position;
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),
_KeyOfValue()(__v)))
{
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
return _M_insert_(__position._M_node,
- __position._M_node, __v);
+ __position._M_node,
+ _GLIBCXX_FORWARD(_Arg, __v));
}
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),
_KeyOfValue()(__v)))
// ... then try after.
const_iterator __after = __position;
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),
_S_key((++__after)._M_node)))
{
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
- return _M_insert_(__after._M_node, __after._M_node, __v);
+ return _M_insert_(__after._M_node, __after._M_node,
+ _GLIBCXX_FORWARD(_Arg, __v));
}
else
- return _M_insert_unique(__v).first;
+ return _M_insert_unique(_GLIBCXX_FORWARD(_Arg, __v)).first;
}
else
// Equivalent keys.
template<typename _Key, typename _Val, typename _KeyOfValue,
typename _Compare, typename _Alloc>
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+ template<typename _Arg>
+#endif
typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator
_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)
+#endif
{
// end()
if (__position._M_node == _M_end())
if (size() > 0
&& !_M_impl._M_key_compare(_KeyOfValue()(__v),
_S_key(_M_rightmost())))
- return _M_insert_(0, _M_rightmost(), __v);
+ return _M_insert_(0, _M_rightmost(),
+ _GLIBCXX_FORWARD(_Arg, __v));
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),
_KeyOfValue()(__v)))
// First, try before...
const_iterator __before = __position;
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),
_S_key((--__before)._M_node)))
{
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
return _M_insert_(__position._M_node,
- __position._M_node, __v);
+ __position._M_node,
+ _GLIBCXX_FORWARD(_Arg, __v));
}
else
- return _M_insert_equal(__v);
+ return _M_insert_equal(_GLIBCXX_FORWARD(_Arg, __v));
}
else
{
// ... then try after.
const_iterator __after = __position;
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),
_KeyOfValue()(__v)))
{
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
- return _M_insert_(__after._M_node, __after._M_node, __v);
+ return _M_insert_(__after._M_node, __after._M_node,
+ _GLIBCXX_FORWARD(_Arg, __v));
}
else
- return _M_insert_equal_lower(__v);
+ return _M_insert_equal_lower(_GLIBCXX_FORWARD(_Arg, __v));
}
}
}
#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
insert(std::initializer_list<value_type> __list)
{ _Base::insert(__list); }
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>
void
insert(_InputIterator __first, _InputIterator __last)
{ return iterator(_Base::insert(__x), this); }
#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
insert(std::initializer_list<value_type> __list)
{ _Base::insert(__list); }
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>
void
insert(_InputIterator __first, _InputIterator __last)
insert(const value_type& __x)
{ 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
insert(iterator __position, const value_type& __x)
{
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>
void
insert(_InputIterator __first, _InputIterator __last)
__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
insert(iterator __position, const value_type& __x)
{
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>
void
insert(_InputIterator __first, _InputIterator __last)
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&
at(const key_type& __k)
{
}
#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
insert(std::initializer_list<value_type> __list)
{
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>
void
insert(_InputIterator __first, _InputIterator __last)
{ return iterator(_Base::insert(__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 iterator(_Base::insert(std::forward<_Pair>(__x))); }
+#endif
+
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
void
insert(std::initializer_list<value_type> __list)
{ _Base::insert(__list); }
#endif
{ 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>
void
insert(_InputIterator __first, _InputIterator __last)
insert(const value_type& __x)
{ return iterator(_Base::insert(__x)); }
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+ iterator
+ insert(value_type&& __x)
+ { return iterator(_Base::insert(std::move(__x))); }
+#endif
+
iterator
#ifdef __GXX_EXPERIMENTAL_CXX0X__
insert(const_iterator __position, const value_type& __x)
#endif
{ 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>
void
insert(_InputIterator __first, _InputIterator __last)
__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
#ifdef __GXX_EXPERIMENTAL_CXX0X__
insert(const_iterator __position, const value_type& __x)
#endif
{ 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>
void
insert(_InputIterator __first, _InputIterator __last)
--- /dev/null
+// { 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;
+}
--- /dev/null
+// { 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];
+}
--- /dev/null
+// { 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;
+}
--- /dev/null
+// { 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;
+}
--- /dev/null
+// { 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;
+}
--- /dev/null
+// { 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;
+}
--- /dev/null
+// { 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;
+}
--- /dev/null
+// { 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;
+}
--- /dev/null
+// { 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;
+}
--- /dev/null
+// { 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;
+}
--- /dev/null
+// { 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;
+}
--- /dev/null
+// { 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;
+}
--- /dev/null
+// { 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;
+}
--- /dev/null
+// { 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;
+}