Commit 8f47a7f6 by Paolo Carlini Committed by Paolo Carlini

forward_list.h (forward_list<>::max_size): Use Node_allocator; minor cosmetic changes.

2008-10-15  Paolo Carlini  <paolo.carlini@oracle.com>

	* include/bits/forward_list.h (forward_list<>::max_size): Use
	Node_allocator; minor cosmetic changes.
	* testsuite/23_containers/forward_list/capacity/1.cc: Adjust.

From-SVN: r141151
parent bf520698
2008-10-15 Paolo Carlini <paolo.carlini@oracle.com>
* include/bits/forward_list.h (forward_list<>::max_size): Use
Node_allocator; minor cosmetic changes.
* testsuite/23_containers/forward_list/capacity/1.cc: Adjust.
2008-10-15 Edward Smith-Rowland <3dw4rd@verizon.net> 2008-10-15 Edward Smith-Rowland <3dw4rd@verizon.net>
* include/std/forward_list: New. * include/std/forward_list: New.
......
...@@ -604,9 +604,9 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -604,9 +604,9 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
* that the resulting %forward_list's size is the same as the number * that the resulting %forward_list's size is the same as the number
* of elements assigned. Old data may be lost. * of elements assigned. Old data may be lost.
*/ */
template<typename InputIterator> template<typename _InputIterator>
void void
assign(InputIterator __first, InputIterator __last) assign(_InputIterator __first, _InputIterator __last)
{ {
clear(); clear();
insert_after(cbefore_begin(), __first, __last); insert_after(cbefore_begin(), __first, __last);
...@@ -743,7 +743,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -743,7 +743,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
*/ */
size_type size_type
max_size() const max_size() const
{ return _Alloc().max_size(); } { return this->_M_get_Node_allocator().max_size(); }
// 23.2.3.3 element access: // 23.2.3.3 element access:
...@@ -783,9 +783,9 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -783,9 +783,9 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
* and references. * and references.
*/ */
template<typename... _Args> template<typename... _Args>
void void
emplace_front(_Args&&... __args) emplace_front(_Args&&... __args)
{ _M_insert_after(cbefore_begin(), std::forward<_Args>(__args)...); } { _M_insert_after(cbefore_begin(), std::forward<_Args>(__args)...); }
/** /**
* @brief Add data to the front of the %forward_list. * @brief Add data to the front of the %forward_list.
...@@ -838,9 +838,9 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -838,9 +838,9 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
* and references. * and references.
*/ */
template<typename... _Args> template<typename... _Args>
iterator iterator
emplace_after(const_iterator __pos, _Args&&... __args) emplace_after(const_iterator __pos, _Args&&... __args)
{ _M_insert_after(__pos, std::forward<_Args>(__args)...); } { _M_insert_after(__pos, std::forward<_Args>(__args)...); }
/** /**
* @brief Inserts given value into %forward_list after specified * @brief Inserts given value into %forward_list after specified
...@@ -893,8 +893,8 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -893,8 +893,8 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
* does not invalidate iterators and references. * does not invalidate iterators and references.
*/ */
void void
insert_after(const_iterator __pos, insert_after(const_iterator __pos, size_type __n,
size_type __n, const _Tp& __val); const _Tp& __val);
/** /**
* @brief Inserts a range into the %forward_list. * @brief Inserts a range into the %forward_list.
...@@ -1055,8 +1055,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -1055,8 +1055,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
* Requires this != @a x. * Requires this != @a x.
*/ */
void void
splice_after(const_iterator __pos, splice_after(const_iterator __pos, forward_list&& __list)
forward_list&& __list)
{ {
if (!__list.empty() && &__list != this) if (!__list.empty() && &__list != this)
{ {
...@@ -1079,8 +1078,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -1079,8 +1078,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
* inserts it into the current list after @a pos. * inserts it into the current list after @a pos.
*/ */
void void
splice_after(const_iterator __pos, splice_after(const_iterator __pos, forward_list&& __list,
forward_list&& __list,
const_iterator __it) const_iterator __it)
{ this->splice_after(__pos, __list, __it, __it._M_next()); } { this->splice_after(__pos, __list, __it, __it._M_next()); }
...@@ -1098,10 +1096,8 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -1098,10 +1096,8 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
* Undefined if @a pos is in (before,last). * Undefined if @a pos is in (before,last).
*/ */
void void
splice_after(const_iterator __pos, splice_after(const_iterator __pos, forward_list&& __list,
forward_list&& __list, const_iterator __before, const_iterator __last)
const_iterator __before,
const_iterator __last)
{ {
_Fwd_list_node_base* __tmp _Fwd_list_node_base* __tmp
= const_cast<_Fwd_list_node_base* const>(__pos._M_node); = const_cast<_Fwd_list_node_base* const>(__pos._M_node);
......
...@@ -39,7 +39,8 @@ test01() ...@@ -39,7 +39,8 @@ test01()
fld.resize(0); fld.resize(0);
VERIFY(fld.empty() == true); VERIFY(fld.empty() == true);
VERIFY(fld.max_size() == fld.get_allocator().max_size()); VERIFY( fld.max_size()
== std::allocator<std::_Fwd_list_node<double> >().max_size() );
} }
int int
......
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