+2007-11-11 Paolo Carlini <pcarlini@suse.de>
+
+ * include/bits/stl_list.h (list<>::_M_create_node<>(_Args&&...),
+ _M_insert<>(iterator, _Args&&...), push_front<>(_Args&&...),
+ push_back<>(_Args&&...)): Add.
+ (list<>::emplace<>(iterator, _Args&&...), insert(iterator,
+ value_type&&)): Declare.
+ (splice(iterator, list&&), splice(iterator, list&&, iterator),
+ splice(iterator, list&&, iterator, iterator), merge(list&&),
+ merge(list&&, _StrictWeakOrdering)): Add C++0x signatures.
+ * include/bits/list.tcc (list<>::emplace<>(iterator, _Args&&...),
+ insert(iterator, value_type&&)): Define.
+ * include/debug/list (list<>::emplace<>(iterator, _Args&&...),
+ insert(iterator, value_type&&)): Add.
+ (splice(iterator, list&&), splice(iterator, list&&, iterator),
+ splice(iterator, list&&, iterator, iterator), merge(list&&),
+ merge(list&&, _StrictWeakOrdering)): Add C++0x signatures, use
+ _GLIBCXX_MOVE.
+
2007-11-09 Paolo Carlini <pcarlini@suse.de>
* include/bits/stl_deque.h (deque<>::operator=(deque&&)): Implement
}
}
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+ template<typename _Tp, typename _Alloc>
+ template<typename... _Args>
+ typename list<_Tp, _Alloc>::iterator
+ list<_Tp, _Alloc>::
+ emplace(iterator __position, _Args&&... __args)
+ {
+ _Node* __tmp = _M_create_node(std::forward<_Args>(__args)...);
+ __tmp->hook(__position._M_node);
+ return iterator(__tmp);
+ }
+#endif
+
template<typename _Tp, typename _Alloc>
typename list<_Tp, _Alloc>::iterator
list<_Tp, _Alloc>::
return iterator(__tmp);
}
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+ template<typename _Tp, typename _Alloc>
+ typename list<_Tp, _Alloc>::iterator
+ list<_Tp, _Alloc>::
+ insert(iterator __position, value_type&& __x)
+ {
+ _Node* __tmp = _M_create_node(std::move(__x));
+ __tmp->hook(__position._M_node);
+ return iterator(__tmp);
+ }
+#endif
+
template<typename _Tp, typename _Alloc>
typename list<_Tp, _Alloc>::iterator
list<_Tp, _Alloc>::
template<typename _Tp, typename _Alloc>
void
list<_Tp, _Alloc>::
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+ merge(list&& __x)
+#else
merge(list& __x)
+#endif
{
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 300. list::merge() specification incomplete
template <typename _StrictWeakOrdering>
void
list<_Tp, _Alloc>::
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+ merge(list&& __x, _StrictWeakOrdering __comp)
+#else
merge(list& __x, _StrictWeakOrdering __comp)
+#endif
{
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 300. list::merge() specification incomplete
* Allocates space for a new node and constructs a copy of @a x in it.
* @endif
*/
+#ifndef __GXX_EXPERIMENTAL_CXX0X__
_Node*
_M_create_node(const value_type& __x)
{
}
return __p;
}
+#else
+ template<typename... _Args>
+ _Node*
+ _M_create_node(_Args&&... __args)
+ {
+ _Node* __p = this->_M_get_node();
+ try
+ {
+ _M_get_Tp_allocator().construct(&__p->_M_data,
+ std::forward<_Args>(__args)...);
+ }
+ catch(...)
+ {
+ _M_put_node(__p);
+ __throw_exception_again;
+ }
+ return __p;
+ }
+#endif
public:
// [23.2.2.1] construct/copy/destroy
* done in constant time, and does not invalidate iterators and
* references.
*/
+#ifndef __GXX_EXPERIMENTAL_CXX0X__
void
push_front(const value_type& __x)
{ this->_M_insert(begin(), __x); }
+#else
+ template<typename... _Args>
+ void
+ push_front(_Args&&... __args)
+ { this->_M_insert(begin(), std::forward<_Args>(__args)...); }
+#endif
/**
* @brief Removes first element.
* in constant time, and does not invalidate iterators and
* references.
*/
+#ifndef __GXX_EXPERIMENTAL_CXX0X__
void
push_back(const value_type& __x)
{ this->_M_insert(end(), __x); }
+#else
+ template<typename... _Args>
+ void
+ push_back(_Args&&... __args)
+ { this->_M_insert(end(), std::forward<_Args>(__args)...); }
+#endif
/**
* @brief Removes last element.
pop_back()
{ this->_M_erase(iterator(this->_M_impl._M_node._M_prev)); }
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+ /**
+ * @brief Constructs object in %list before specified iterator.
+ * @param position A const_iterator into the %list.
+ * @param args Arguments.
+ * @return An iterator that points to the inserted data.
+ *
+ * This function will insert an object of type T constructed
+ * with T(std::forward<Args>(args)...) before the specified
+ * location. Due to the nature of a %list this operation can
+ * be done in constant time, and does not invalidate iterators
+ * and references.
+ */
+ template<typename... _Args>
+ iterator
+ emplace(iterator __position, _Args&&... __args);
+#endif
+
/**
* @brief Inserts given value into %list before specified iterator.
* @param position An iterator into the %list.
iterator
insert(iterator __position, const value_type& __x);
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+ /**
+ * @brief Inserts given rvalue into %list before specified iterator.
+ * @param position An iterator into the %list.
+ * @param x Data to be inserted.
+ * @return An iterator that points to the inserted data.
+ *
+ * This function will insert a copy of the given rvalue before
+ * the specified location. Due to the nature of a %list this
+ * operation can be done in constant time, and does not
+ * invalidate iterators and references.
+ */
+ iterator
+ insert(iterator __position, value_type&& __x);
+#endif
+
/**
* @brief Inserts a number of copies of given data into the %list.
* @param position An iterator into the %list.
* Requires this != @a x.
*/
void
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+ splice(iterator __position, list&& __x)
+#else
splice(iterator __position, list& __x)
+#endif
{
if (!__x.empty())
{
* inserts it into the current list before @a position.
*/
void
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+ splice(iterator __position, list&& __x, iterator __i)
+#else
splice(iterator __position, list& __x, iterator __i)
+#endif
{
iterator __j = __i;
++__j;
* Undefined if @a position is in [first,last).
*/
void
- splice(iterator __position, list& __x, iterator __first, iterator __last)
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+ splice(iterator __position, list&& __x, iterator __first,
+ iterator __last)
+#else
+ splice(iterator __position, list& __x, iterator __first,
+ iterator __last)
+#endif
{
if (__first != __last)
{
* this list precede elements in @a x that are equal.
*/
void
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+ merge(list&& __x);
+#else
merge(list& __x);
+#endif
/**
* @brief Merge sorted lists according to comparison function.
*/
template<typename _StrictWeakOrdering>
void
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+ merge(list&&, _StrictWeakOrdering);
+#else
merge(list&, _StrictWeakOrdering);
+#endif
/**
* @brief Reverse the elements in list.
{ __position._M_node->transfer(__first._M_node, __last._M_node); }
// Inserts new element at position given and with value given.
+#ifndef __GXX_EXPERIMENTAL_CXX0X__
void
_M_insert(iterator __position, const value_type& __x)
{
_Node* __tmp = _M_create_node(__x);
__tmp->hook(__position._M_node);
}
+#else
+ template<typename... _Args>
+ void
+ _M_insert(iterator __position, _Args&&... __args)
+ {
+ _Node* __tmp = _M_create_node(std::forward<_Args>(__args)...);
+ __tmp->hook(__position._M_node);
+ }
+#endif
// Erases element at position given.
void
_Base::pop_back();
}
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+ template<typename... _Args>
+ iterator
+ emplace(iterator __position, _Args&&... __args)
+ {
+ __glibcxx_check_insert(__position);
+ return iterator(_Base::emplace(__position.base(),
+ std::forward<_Args>(__args)...), this);
+ }
+#endif
+
iterator
insert(iterator __position, const _Tp& __x)
{
return iterator(_Base::insert(__position.base(), __x), this);
}
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+ iterator
+ insert(iterator __position, _Tp&& __x)
+ {
+ __glibcxx_check_insert(__position);
+ return iterator(_Base::insert(__position.base(),
+ std::move(__x)), this);
+ }
+#endif
+
void
insert(iterator __position, size_type __n, const _Tp& __x)
{
// 23.2.2.4 list operations:
void
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+ splice(iterator __position, list&& __x)
+#else
splice(iterator __position, list& __x)
+#endif
{
_GLIBCXX_DEBUG_VERIFY(&__x != this,
_M_message(__gnu_debug::__msg_self_splice)
._M_sequence(*this, "this"));
- this->splice(__position, __x, __x.begin(), __x.end());
+ this->splice(__position, _GLIBCXX_MOVE(__x), __x.begin(), __x.end());
}
void
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+ splice(iterator __position, list&& __x, iterator __i)
+#else
splice(iterator __position, list& __x, iterator __i)
+#endif
{
__glibcxx_check_insert(__position);
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 250. splicing invalidates iterators
this->_M_transfer_iter(__i);
- _Base::splice(__position.base(), __x._M_base(), __i.base());
+ _Base::splice(__position.base(), _GLIBCXX_MOVE(__x._M_base()),
+ __i.base());
}
void
- splice(iterator __position, list& __x, iterator __first, iterator __last)
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+ splice(iterator __position, list&& __x, iterator __first,
+ iterator __last)
+#else
+ splice(iterator __position, list& __x, iterator __first,
+ iterator __last)
+#endif
{
__glibcxx_check_insert(__position);
__glibcxx_check_valid_range(__first, __last);
this->_M_transfer_iter(__victim);
}
- _Base::splice(__position.base(), __x._M_base(), __first.base(),
- __last.base());
+ _Base::splice(__position.base(), _GLIBCXX_MOVE(__x._M_base()),
+ __first.base(), __last.base());
}
void
}
void
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+ merge(list&& __x)
+#else
merge(list& __x)
+#endif
{
__glibcxx_check_sorted(_Base::begin(), _Base::end());
__glibcxx_check_sorted(__x.begin().base(), __x.end().base());
iterator __victim = __tmp++;
__victim._M_attach(&__x);
}
- _Base::merge(__x._M_base());
+ _Base::merge(_GLIBCXX_MOVE(__x._M_base()));
}
template<class _Compare>
void
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+ merge(list&& __x, _Compare __comp)
+#else
merge(list& __x, _Compare __comp)
+#endif
{
__glibcxx_check_sorted_pred(_Base::begin(), _Base::end(), __comp);
__glibcxx_check_sorted_pred(__x.begin().base(), __x.end().base(),
iterator __victim = __tmp++;
__victim._M_attach(&__x);
}
- _Base::merge(__x._M_base(), __comp);
+ _Base::merge(_GLIBCXX_MOVE(__x._M_base()), __comp);
}
void
// USA.
// { dg-do compile }
-// { dg-error "no matching" "" { target *-*-* } 1236 }
+// { dg-error "no matching" "" { target *-*-* } 1326 }
// { dg-excess-errors "" }
#include <list>
// USA.
// { dg-do compile }
-// { dg-error "no matching" "" { target *-*-* } 1205 }
+// { dg-error "no matching" "" { target *-*-* } 1295 }
// { dg-excess-errors "" }
#include <list>
// USA.
// { dg-do compile }
-// { dg-error "no matching" "" { target *-*-* } 1205 }
+// { dg-error "no matching" "" { target *-*-* } 1295 }
// { dg-excess-errors "" }
#include <list>
// USA.
// { dg-do compile }
-// { dg-error "no matching" "" { target *-*-* } 1205 }
+// { dg-error "no matching" "" { target *-*-* } 1295 }
// { dg-excess-errors "" }
#include <list>