]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR libstdc++/32618 (std::vector calls uneccessary constructors instead of inplace...
authorPaolo Carlini <paolo.carlini@oracle.com>
Fri, 18 Jun 2010 18:07:45 +0000 (18:07 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Fri, 18 Jun 2010 18:07:45 +0000 (18:07 +0000)
2010-06-18  Paolo Carlini  <paolo.carlini@oracle.com>

PR libstdc++/32618
* include/bits/stl_list.h (vector<>::_M_default_initialize,
_M_default_append): Declare.
(list<>::list(size_type), resize(size_type)): Add in C++0x mode,
use the latter.
* include/bits/list.tcc (list<>::resize, _M_default_append): Define.
* include/bits/stl_vector.h (vector<>::_M_default_initialize,
_M_default_append): Declare.
(vector<>::vector(size_type), resize(size_type)): Add in C++0x mode,
use the latter.
* include/bits/vector.tcc (vector<>::_M_default_append): Define.
* include/bits/stl_deque.h (deque<>::_M_default_initialize,
_M_default_append): Declare.
(deque<>::deque(size_type), resize(size_type)): Add in C++0x mode,
use the latter.
* include/bits/deque.tcc (deque<>::_M_default_append): Define.
* include/debug/vector: Update.
* include/debug/deque: Likewise.
* include/debug/list: Likewise.
* include/profile/vector: Likewise.
* include/profile/deque: Likewise.
* include/profile/list: Likewise.
* include/bits/forward_list.h (_M_default_initialize,
_M_default_insert_after): Declare.
(forward_list<>::forward_list(size_type), resize(size_type)): Fix,
use the latter.
* include/bits/forward_list.tcc (forward_list<>::_M_default_append,
_M_default_insert_after): Define.
* testsuite/util/testsuite_api.h (NonCopyConstructible): Add.
* testsuite/23_containers/forward_list/modifiers/6.cc: Move to...
* testsuite/23_containers/forward_list/capacity/resize_size.cc:
... here.
* testsuite/23_containers/forward_list/cons/10.cc: Move to...
* testsuite/23_containers/forward_list/cons/cons_size.cc: ... here.
* testsuite/23_containers/vector/resize/1.cc: Move to...
* testsuite/23_containers/vector/capacity/resize/1.cc: ... here.
* testsuite/23_containers/vector/resize/moveable.cc: Move to...
* testsuite/23_containers/vector/resize/capacity/moveable.cc: ... here.
* testsuite/23_containers/vector/cons/cons_size.cc: New.
* testsuite/23_containers/vector/capacity/resize/resize_size.cc:
Likewise.
* testsuite/23_containers/deque/cons/cons_size.cc: Likewise.
* testsuite/23_containers/deque/capacity/resize_size.cc: Likewise.
* testsuite/23_containers/list/cons/cons_size.cc: Likewise.
* testsuite/23_containers/list/capacity/resize_size.cc: Likewise.
* testsuite/23_containers/vector/capacity/resize/moveable.cc: Adjust.
* testsuite/23_containers/deque/capacity/moveable.cc: Likewise.
* testsuite/23_containers/forward_list/requirements/dr438/
assign_neg.cc: Adjust dg-error line numbers.
* testsuite/23_containers/forward_list/requirements/dr438/
insert_neg.cc: Likewise.
* testsuite/23_containers/forward_list/requirements/dr438/
constructor_1_neg.cc: Likewise.
* testsuite/23_containers/forward_list/requirements/dr438/
constructor_2_neg.cc: Likewise.
* testsuite/23_containers/vector/requirements/dr438/
assign_neg.cc: Likewise.
* testsuite/23_containers/vector/requirements/dr438/insert_neg.cc:
Likewise.
* testsuite/23_containers/vector/requirements/dr438/
constructor_1_neg.cc: Likewise.
* testsuite/23_containers/vector/requirements/dr438/
constructor_2_neg.cc: Likewise.
* testsuite/23_containers/deque/requirements/dr438/
assign_neg.cc: Likewise.
* testsuite/23_containers/deque/requirements/dr438/insert_neg.cc:
Likewise.
* testsuite/23_containers/deque/requirements/dr438/
constructor_1_neg.cc: Likewise.
* testsuite/23_containers/deque/requirements/dr438/
constructor_2_neg.cc: Likewise.
* testsuite/23_containers/list/requirements/dr438/assign_neg.cc:
Likewise.
* testsuite/23_containers/list/requirements/dr438/insert_neg.cc:
Likewise.
* testsuite/23_containers/list/requirements/dr438/
constructor_1_neg.cc: Likewise.
* testsuite/23_containers/list/requirements/dr438/
constructor_2_neg.cc: Likewise.

From-SVN: r161009

43 files changed:
libstdc++-v3/ChangeLog
libstdc++-v3/include/bits/deque.tcc
libstdc++-v3/include/bits/forward_list.h
libstdc++-v3/include/bits/forward_list.tcc
libstdc++-v3/include/bits/list.tcc
libstdc++-v3/include/bits/stl_deque.h
libstdc++-v3/include/bits/stl_list.h
libstdc++-v3/include/bits/stl_vector.h
libstdc++-v3/include/bits/vector.tcc
libstdc++-v3/include/debug/deque
libstdc++-v3/include/debug/list
libstdc++-v3/include/debug/vector
libstdc++-v3/include/profile/deque
libstdc++-v3/include/profile/list
libstdc++-v3/include/profile/vector
libstdc++-v3/testsuite/23_containers/deque/capacity/moveable.cc
libstdc++-v3/testsuite/23_containers/deque/capacity/resize_size.cc [new file with mode: 0644]
libstdc++-v3/testsuite/23_containers/deque/cons/cons_size.cc [new file with mode: 0644]
libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/assign_neg.cc
libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/constructor_1_neg.cc
libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/constructor_2_neg.cc
libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/insert_neg.cc
libstdc++-v3/testsuite/23_containers/forward_list/capacity/resize_size.cc [moved from libstdc++-v3/testsuite/23_containers/forward_list/cons/10.cc with 79% similarity]
libstdc++-v3/testsuite/23_containers/forward_list/cons/cons_size.cc [moved from libstdc++-v3/testsuite/23_containers/forward_list/modifiers/6.cc with 75% similarity]
libstdc++-v3/testsuite/23_containers/forward_list/requirements/dr438/assign_neg.cc
libstdc++-v3/testsuite/23_containers/forward_list/requirements/dr438/constructor_1_neg.cc
libstdc++-v3/testsuite/23_containers/forward_list/requirements/dr438/constructor_2_neg.cc
libstdc++-v3/testsuite/23_containers/forward_list/requirements/dr438/insert_neg.cc
libstdc++-v3/testsuite/23_containers/list/capacity/resize_size.cc [new file with mode: 0644]
libstdc++-v3/testsuite/23_containers/list/cons/cons_size.cc [new file with mode: 0644]
libstdc++-v3/testsuite/23_containers/list/requirements/dr438/assign_neg.cc
libstdc++-v3/testsuite/23_containers/list/requirements/dr438/constructor_1_neg.cc
libstdc++-v3/testsuite/23_containers/list/requirements/dr438/constructor_2_neg.cc
libstdc++-v3/testsuite/23_containers/list/requirements/dr438/insert_neg.cc
libstdc++-v3/testsuite/23_containers/vector/capacity/resize/1.cc [moved from libstdc++-v3/testsuite/23_containers/vector/resize/1.cc with 100% similarity]
libstdc++-v3/testsuite/23_containers/vector/capacity/resize/moveable.cc [moved from libstdc++-v3/testsuite/23_containers/vector/resize/moveable.cc with 50% similarity]
libstdc++-v3/testsuite/23_containers/vector/capacity/resize/resize_size.cc [new file with mode: 0644]
libstdc++-v3/testsuite/23_containers/vector/cons/cons_size.cc [new file with mode: 0644]
libstdc++-v3/testsuite/23_containers/vector/requirements/dr438/assign_neg.cc
libstdc++-v3/testsuite/23_containers/vector/requirements/dr438/constructor_1_neg.cc
libstdc++-v3/testsuite/23_containers/vector/requirements/dr438/constructor_2_neg.cc
libstdc++-v3/testsuite/23_containers/vector/requirements/dr438/insert_neg.cc
libstdc++-v3/testsuite/util/testsuite_api.h

index e0c2f30444c0d5403ce7d8a1567d2323826bfec8..58410cca40c33950fd312c5be8867bb048949d67 100644 (file)
@@ -1,3 +1,85 @@
+2010-06-18  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR libstdc++/32618
+       * include/bits/stl_list.h (vector<>::_M_default_initialize,
+       _M_default_append): Declare.
+       (list<>::list(size_type), resize(size_type)): Add in C++0x mode,
+       use the latter.
+       * include/bits/list.tcc (list<>::resize, _M_default_append): Define.
+       * include/bits/stl_vector.h (vector<>::_M_default_initialize,
+       _M_default_append): Declare.
+       (vector<>::vector(size_type), resize(size_type)): Add in C++0x mode,
+       use the latter.
+       * include/bits/vector.tcc (vector<>::_M_default_append): Define.
+       * include/bits/stl_deque.h (deque<>::_M_default_initialize,
+       _M_default_append): Declare.
+       (deque<>::deque(size_type), resize(size_type)): Add in C++0x mode,
+       use the latter.
+       * include/bits/deque.tcc (deque<>::_M_default_append): Define.
+       * include/debug/vector: Update.
+       * include/debug/deque: Likewise.
+       * include/debug/list: Likewise.
+       * include/profile/vector: Likewise.
+       * include/profile/deque: Likewise.
+       * include/profile/list: Likewise.
+       * include/bits/forward_list.h (_M_default_initialize,
+       _M_default_insert_after): Declare.
+       (forward_list<>::forward_list(size_type), resize(size_type)): Fix,
+       use the latter.
+       * include/bits/forward_list.tcc (forward_list<>::_M_default_append,
+       _M_default_insert_after): Define.
+       * testsuite/util/testsuite_api.h (NonCopyConstructible): Add.
+       * testsuite/23_containers/forward_list/modifiers/6.cc: Move to...
+       * testsuite/23_containers/forward_list/capacity/resize_size.cc:
+       ... here.
+       * testsuite/23_containers/forward_list/cons/10.cc: Move to...
+       * testsuite/23_containers/forward_list/cons/cons_size.cc: ... here.
+       * testsuite/23_containers/vector/resize/1.cc: Move to...
+       * testsuite/23_containers/vector/capacity/resize/1.cc: ... here.
+       * testsuite/23_containers/vector/resize/moveable.cc: Move to...
+       * testsuite/23_containers/vector/resize/capacity/moveable.cc: ... here.
+       * testsuite/23_containers/vector/cons/cons_size.cc: New.
+       * testsuite/23_containers/vector/capacity/resize/resize_size.cc:
+       Likewise.
+       * testsuite/23_containers/deque/cons/cons_size.cc: Likewise.
+       * testsuite/23_containers/deque/capacity/resize_size.cc: Likewise.
+       * testsuite/23_containers/list/cons/cons_size.cc: Likewise.
+       * testsuite/23_containers/list/capacity/resize_size.cc: Likewise.
+       * testsuite/23_containers/vector/capacity/resize/moveable.cc: Adjust.
+       * testsuite/23_containers/deque/capacity/moveable.cc: Likewise.
+       * testsuite/23_containers/forward_list/requirements/dr438/
+       assign_neg.cc: Adjust dg-error line numbers.
+       * testsuite/23_containers/forward_list/requirements/dr438/
+       insert_neg.cc: Likewise.
+       * testsuite/23_containers/forward_list/requirements/dr438/
+       constructor_1_neg.cc: Likewise.
+       * testsuite/23_containers/forward_list/requirements/dr438/
+       constructor_2_neg.cc: Likewise.
+       * testsuite/23_containers/vector/requirements/dr438/
+       assign_neg.cc: Likewise.
+       * testsuite/23_containers/vector/requirements/dr438/insert_neg.cc:
+       Likewise.
+       * testsuite/23_containers/vector/requirements/dr438/
+       constructor_1_neg.cc: Likewise.
+       * testsuite/23_containers/vector/requirements/dr438/
+       constructor_2_neg.cc: Likewise.
+       * testsuite/23_containers/deque/requirements/dr438/
+       assign_neg.cc: Likewise.
+       * testsuite/23_containers/deque/requirements/dr438/insert_neg.cc:
+       Likewise.
+       * testsuite/23_containers/deque/requirements/dr438/
+       constructor_1_neg.cc: Likewise.
+       * testsuite/23_containers/deque/requirements/dr438/
+       constructor_2_neg.cc: Likewise.
+       * testsuite/23_containers/list/requirements/dr438/assign_neg.cc:
+       Likewise.
+       * testsuite/23_containers/list/requirements/dr438/insert_neg.cc:
+       Likewise.
+       * testsuite/23_containers/list/requirements/dr438/
+       constructor_1_neg.cc: Likewise.
+       * testsuite/23_containers/list/requirements/dr438/
+       constructor_2_neg.cc: Likewise.
+
 2010-06-17  Paolo Carlini  <paolo.carlini@oracle.com>
 
        * include/bits/stl_uninitialized.h (__uninitialized_default,
index cde067cf382c1da5aa4bc2573912b97bfeb74eee..d8c2787064727eb44f304990dee845a93bfd02db 100644 (file)
@@ -1,6 +1,7 @@
 // Deque implementation (out of line) -*- C++ -*-
 
-// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
+// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
+// 2009, 2010
 // Free Software Foundation, Inc.
 //
 // This file is part of the GNU ISO C++ Library.  This library is free
 
 _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
 
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+  template <typename _Tp, typename _Alloc>
+    void
+    deque<_Tp, _Alloc>::
+    _M_default_initialize()
+    {
+      _Map_pointer __cur;
+      __try
+        {
+          for (__cur = this->_M_impl._M_start._M_node;
+              __cur < this->_M_impl._M_finish._M_node;
+              ++__cur)
+            std::__uninitialized_default_a(*__cur, *__cur + _S_buffer_size(),
+                                          _M_get_Tp_allocator());
+          std::__uninitialized_default_a(this->_M_impl._M_finish._M_first,
+                                        this->_M_impl._M_finish._M_cur,
+                                        _M_get_Tp_allocator());
+        }
+      __catch(...)
+        {
+          std::_Destroy(this->_M_impl._M_start, iterator(*__cur, __cur),
+                       _M_get_Tp_allocator());
+          __throw_exception_again;
+        }
+    }
+#endif
+
   template <typename _Tp, typename _Alloc>
     deque<_Tp, _Alloc>&
     deque<_Tp, _Alloc>::
@@ -271,6 +299,32 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
         _M_insert_aux(__pos, __n, __x);
     }
 
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+  template <typename _Tp, typename _Alloc>
+    void
+    deque<_Tp, _Alloc>::
+    _M_default_append(size_type __n)
+    {
+      if (__n)
+       {
+         iterator __new_finish = _M_reserve_elements_at_back(__n);
+         __try
+           {
+             std::__uninitialized_default_a(this->_M_impl._M_finish,
+                                            __new_finish,
+                                            _M_get_Tp_allocator());
+             this->_M_impl._M_finish = __new_finish;
+           }
+         __catch(...)
+           {
+             _M_destroy_nodes(this->_M_impl._M_finish._M_node + 1,
+                              __new_finish._M_node + 1);
+             __throw_exception_again;
+           }
+       }
+    }
+#endif
+
   template <typename _Tp, typename _Alloc>
     void
     deque<_Tp, _Alloc>::
index c0c135cd1b36bc9b0f0a22882e5ed6f208dbba06..3708a62c37d3e441a428f2faead64638059a63f6 100644 (file)
@@ -463,7 +463,9 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
        *  constructed elements.
        */
       explicit
-      forward_list(size_type __n);
+      forward_list(size_type __n)
+      : _Base()
+      { _M_default_initialize(__n); }
 
       /**
        *  @brief  Creates a %forward_list with copies of an exemplar element.
@@ -1209,6 +1211,14 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
       // Called by splice_after and insert_after.
       iterator
       _M_splice_after(const_iterator __pos, forward_list&& __list);
+
+      // Called by forward_list(n).
+      void
+      _M_default_initialize(size_type __n);
+
+      // Called by resize(sz).
+      void
+      _M_default_insert_after(const_iterator __pos, size_type __n);
     };
 
   /**
index 7468a90d1afb806bad2d3fb4b9f19a03e42e2f42..a3719a8698d0a63afc06597b4c07cca6d68a400e 100644 (file)
@@ -114,7 +114,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
     _M_fill_initialize(size_type __n, const value_type& __value)
     {
       _Node_base* __to = &this->_M_impl._M_head;
-      for (; __n > 0; --__n)
+      for (; __n; --__n)
         {
           __to->_M_next = this->_M_create_node(__value);
           __to = __to->_M_next;
@@ -122,12 +122,12 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
     }
 
   template<typename _Tp, typename _Alloc>
+    void
     forward_list<_Tp, _Alloc>::
-    forward_list(size_type __n)
-    : _Base()
+    _M_default_initialize(size_type __n)
     {
       _Node_base* __to = &this->_M_impl._M_head;
-      for (; __n > 0; --__n)
+      for (; __n; --__n)
         {
           __to->_M_next = this->_M_create_node();
           __to = __to->_M_next;
@@ -161,6 +161,24 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
       return *this;
     }
 
+  template<typename _Tp, typename _Alloc>
+    void
+    forward_list<_Tp, _Alloc>::
+    _M_default_insert_after(const_iterator __pos, size_type __n)
+    {
+      const_iterator __saved_pos = __pos;
+      __try
+       {
+         for (; __n; --__n)
+           __pos = emplace_after(__pos);
+       }
+      __catch(...)
+       {
+         erase_after(__saved_pos, ++__pos);
+         __throw_exception_again;
+       }
+    }
+
   template<typename _Tp, typename _Alloc>
     void
     forward_list<_Tp, _Alloc>::
@@ -177,10 +195,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
       if (__len == __sz)
         erase_after(__k, end());
       else
-       {
-         forward_list __tmp(__sz - __len);
-         splice_after(__k, std::move(__tmp));
-       }
+       _M_default_insert_after(__k, __sz - __len);
     }
 
   template<typename _Tp, typename _Alloc>
index f1c4a10dd664dd8120c82ede2d88e20ffba703c8..3446c42a85b2e476f1103ce53d488f1f48b13496 100644 (file)
@@ -112,6 +112,56 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
       return __ret;
     }
 
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+  template<typename _Tp, typename _Alloc>
+    void
+    list<_Tp, _Alloc>::
+    _M_default_append(size_type __n)
+    {
+      size_type __i = 0;
+      __try
+       {
+         for (; __i < __n; ++__i)
+           emplace_back();
+       }
+      __catch(...)
+       {
+         for (; __i; --__i)
+           pop_back();
+         __throw_exception_again;
+       }
+    }
+
+  template<typename _Tp, typename _Alloc>
+    void
+    list<_Tp, _Alloc>::
+    resize(size_type __new_size)
+    {
+      iterator __i = begin();
+      size_type __len = 0;
+      for (; __i != end() && __len < __new_size; ++__i, ++__len)
+        ;
+      if (__len == __new_size)
+        erase(__i, end());
+      else                          // __i == end()
+       _M_default_append(__new_size - __len);
+    }
+
+  template<typename _Tp, typename _Alloc>
+    void
+    list<_Tp, _Alloc>::
+    resize(size_type __new_size, const value_type& __x)
+    {
+      iterator __i = begin();
+      size_type __len = 0;
+      for (; __i != end() && __len < __new_size; ++__i, ++__len)
+        ;
+      if (__len == __new_size)
+        erase(__i, end());
+      else                          // __i == end()
+        insert(end(), __new_size - __len, __x);
+    }
+#else
   template<typename _Tp, typename _Alloc>
     void
     list<_Tp, _Alloc>::
@@ -126,6 +176,7 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
       else                          // __i == end()
         insert(end(), __new_size - __len, __x);
     }
+#endif
 
   template<typename _Tp, typename _Alloc>
     list<_Tp, _Alloc>&
index 19022b0cf344e2ca83cf3a5138a7712539543f81..d3cd73997e9eedfeaedce47540b909a5680b068b 100644 (file)
@@ -449,6 +449,10 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
       : _M_impl()
       { _M_initialize_map(0); }
 
+      _Deque_base(size_t __num_elements)
+      : _M_impl()
+      { _M_initialize_map(__num_elements); }
+
       _Deque_base(const allocator_type& __a, size_t __num_elements)
       : _M_impl(__a)
       { _M_initialize_map(__num_elements); }
@@ -773,6 +777,32 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
       deque(const allocator_type& __a)
       : _Base(__a, 0) { }
 
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+      /**
+       *  @brief  Creates a %deque with default constructed elements.
+       *  @param  n  The number of elements to initially create.
+       *
+       *  This constructor fills the %deque with @a n default
+       *  constructed elements.
+       */
+      explicit
+      deque(size_type __n)
+      : _Base(__n)
+      { _M_default_initialize(); }
+
+      /**
+       *  @brief  Creates a %deque with copies of an exemplar element.
+       *  @param  n  The number of elements to initially create.
+       *  @param  value  An element to copy.
+       *  @param  a  An allocator.
+       *
+       *  This constructor fills the %deque with @a n copies of @a value.
+       */
+      deque(size_type __n, const value_type& __value,
+           const allocator_type& __a = allocator_type())
+      : _Base(__a, __n)
+      { _M_fill_initialize(__value); }
+#else
       /**
        *  @brief  Creates a %deque with copies of an exemplar element.
        *  @param  n  The number of elements to initially create.
@@ -786,6 +816,7 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
            const allocator_type& __a = allocator_type())
       : _Base(__a, __n)
       { _M_fill_initialize(__value); }
+#endif
 
       /**
        *  @brief  %Deque copy constructor.
@@ -824,11 +855,11 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
        */
       deque(initializer_list<value_type> __l,
            const allocator_type& __a = allocator_type())
-       : _Base(__a)
-        {
-         _M_range_initialize(__l.begin(), __l.end(),
-                             random_access_iterator_tag());
-       }
+      : _Base(__a)
+      {
+       _M_range_initialize(__l.begin(), __l.end(),
+                           random_access_iterator_tag());
+      }
 #endif
 
       /**
@@ -1086,6 +1117,49 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
       max_size() const
       { return _M_get_Tp_allocator().max_size(); }
 
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+      /**
+       *  @brief  Resizes the %deque to the specified number of elements.
+       *  @param  new_size  Number of elements the %deque should contain.
+       *
+       *  This function will %resize the %deque to the specified
+       *  number of elements.  If the number is smaller than the
+       *  %deque's current size the %deque is truncated, otherwise
+       *  default constructed elements are appended.
+       */
+      void
+      resize(size_type __new_size)
+      {
+       const size_type __len = size();
+       if (__new_size > __len)
+         _M_default_append(__new_size - __len);
+       else if (__new_size < __len)
+         _M_erase_at_end(this->_M_impl._M_start
+                         + difference_type(__new_size));
+      }
+
+      /**
+       *  @brief  Resizes the %deque to the specified number of elements.
+       *  @param  new_size  Number of elements the %deque should contain.
+       *  @param  x  Data with which new elements should be populated.
+       *
+       *  This function will %resize the %deque to the specified
+       *  number of elements.  If the number is smaller than the
+       *  %deque's current size the %deque is truncated, otherwise the
+       *  %deque is extended and new elements are populated with given
+       *  data.
+       */
+      void
+      resize(size_type __new_size, const value_type& __x)
+      {
+       const size_type __len = size();
+       if (__new_size > __len)
+         insert(this->_M_impl._M_finish, __new_size - __len, __x);
+       else if (__new_size < __len)
+         _M_erase_at_end(this->_M_impl._M_start
+                         + difference_type(__new_size));
+      }
+#else
       /**
        *  @brief  Resizes the %deque to the specified number of elements.
        *  @param  new_size  Number of elements the %deque should contain.
@@ -1101,11 +1175,13 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
       resize(size_type __new_size, value_type __x = value_type())
       {
        const size_type __len = size();
-       if (__new_size < __len)
-         _M_erase_at_end(this->_M_impl._M_start + difference_type(__new_size));
-       else
+       if (__new_size > __len)
          insert(this->_M_impl._M_finish, __new_size - __len, __x);
+       else if (__new_size < __len)
+         _M_erase_at_end(this->_M_impl._M_start
+                         + difference_type(__new_size));
       }
+#endif
 
 #ifdef __GXX_EXPERIMENTAL_CXX0X__
       /**  A non-binding request to reduce memory use.  */
@@ -1564,6 +1640,12 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
       void
       _M_fill_initialize(const value_type& __value);
 
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+      // called by deque(n).
+      void
+      _M_default_initialize();
+#endif
+
       // Internal assign functions follow.  The *_aux functions do the actual
       // assignment work for the range versions.
 
@@ -1752,6 +1834,12 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
        this->_M_impl._M_finish = __pos;
       }
 
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+      // Called by resize(sz).
+      void
+      _M_default_append(size_type __n);
+#endif
+
       //@{
       /// Memory-handling helpers for the previous internal insert functions.
       iterator
index 56357ed07da9f94703875dd2261974c417ed5834..d6f9255752fe13fde154c476d07870392872ec25 100644 (file)
@@ -508,6 +508,32 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
       list(const allocator_type& __a)
       : _Base(__a) { }
 
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+      /**
+       *  @brief  Creates a %list with default constructed elements.
+       *  @param  n  The number of elements to initially create.
+       *
+       *  This constructor fills the %list with @a n default
+       *  constructed elements.
+       */
+      explicit
+      list(size_type __n)
+      : _Base()
+      { _M_default_initialize(__n); }
+
+      /**
+       *  @brief  Creates a %list with copies of an exemplar element.
+       *  @param  n  The number of elements to initially create.
+       *  @param  value  An element to copy.
+       *  @param  a  An allocator object.
+       *
+       *  This constructor fills the %list with @a n copies of @a value.
+       */
+      list(size_type __n, const value_type& __value,
+          const allocator_type& __a = allocator_type())
+      : _Base(__a)
+      { _M_fill_initialize(__n, __value); }
+#else
       /**
        *  @brief  Creates a %list with copies of an exemplar element.
        *  @param  n  The number of elements to initially create.
@@ -521,6 +547,7 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
           const allocator_type& __a = allocator_type())
       : _Base(__a)
       { _M_fill_initialize(__n, __value); }
+#endif
 
       /**
        *  @brief  %List copy constructor.
@@ -811,6 +838,32 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
       max_size() const
       { return _M_get_Node_allocator().max_size(); }
 
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+      /**
+       *  @brief Resizes the %list to the specified number of elements.
+       *  @param new_size Number of elements the %list should contain.
+       *
+       *  This function will %resize the %list to the specified number
+       *  of elements.  If the number is smaller than the %list's
+       *  current size the %list is truncated, otherwise default
+       *  constructed elements are appended.
+       */
+      void
+      resize(size_type __new_size);
+
+      /**
+       *  @brief Resizes the %list to the specified number of elements.
+       *  @param new_size Number of elements the %list should contain.
+       *  @param x Data with which new elements should be populated.
+       *
+       *  This function will %resize the %list to the specified number
+       *  of elements.  If the number is smaller than the %list's
+       *  current size the %list is truncated, otherwise the %list is
+       *  extended and new elements are populated with given data.
+       */
+      void
+      resize(size_type __new_size, const value_type& __x);
+#else
       /**
        *  @brief Resizes the %list to the specified number of elements.
        *  @param new_size Number of elements the %list should contain.
@@ -823,6 +876,7 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
        */
       void
       resize(size_type __new_size, value_type __x = value_type());
+#endif
 
       // element access
       /**
@@ -1394,10 +1448,23 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
       void
       _M_fill_initialize(size_type __n, const value_type& __x)
       {
-       for (; __n > 0; --__n)
+       for (; __n; --__n)
          push_back(__x);
       }
 
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+      // Called by list(n).
+      void
+      _M_default_initialize(size_type __n)
+      {
+       for (; __n; --__n)
+         emplace_back();
+      }
+
+      // Called by resize(sz).
+      void
+      _M_default_append(size_type __n);
+#endif
 
       // Internal assign functions follow.
 
index f025b4eeb4511dcff3f2818cec94363779dfdf41..d51578c9e059fe3986c441e2c0a005af7a79acef 100644 (file)
@@ -107,6 +107,14 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
       _Vector_base(const allocator_type& __a)
       : _M_impl(__a) { }
 
+      _Vector_base(size_t __n)
+      : _M_impl()
+      {
+       this->_M_impl._M_start = this->_M_allocate(__n);
+       this->_M_impl._M_finish = this->_M_impl._M_start;
+       this->_M_impl._M_end_of_storage = this->_M_impl._M_start + __n;
+      }
+
       _Vector_base(size_t __n, const allocator_type& __a)
       : _M_impl(__a)
       {
@@ -215,6 +223,32 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
       vector(const allocator_type& __a)
       : _Base(__a) { }
 
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+      /**
+       *  @brief  Creates a %vector with default constructed elements.
+       *  @param  n  The number of elements to initially create.
+       *
+       *  This constructor fills the %vector with @a n default
+       *  constructed elements.
+       */
+      explicit
+      vector(size_type __n)
+      : _Base(__n)
+      { _M_default_initialize(__n); }
+
+      /**
+       *  @brief  Creates a %vector with copies of an exemplar element.
+       *  @param  n  The number of elements to initially create.
+       *  @param  value  An element to copy.
+       *  @param  a  An allocator.
+       *
+       *  This constructor fills the %vector with @a n copies of @a value.
+       */
+      vector(size_type __n, const value_type& __value,
+            const allocator_type& __a = allocator_type())
+      : _Base(__n, __a)
+      { _M_fill_initialize(__n, __value); }
+#else
       /**
        *  @brief  Creates a %vector with copies of an exemplar element.
        *  @param  n  The number of elements to initially create.
@@ -228,6 +262,7 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
             const allocator_type& __a = allocator_type())
       : _Base(__n, __a)
       { _M_fill_initialize(__n, __value); }
+#endif
 
       /**
        *  @brief  %Vector copy constructor.
@@ -538,6 +573,25 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
       max_size() const
       { return _M_get_Tp_allocator().max_size(); }
 
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+      /**
+       *  @brief  Resizes the %vector to the specified number of elements.
+       *  @param  new_size  Number of elements the %vector should contain.
+       *
+       *  This function will %resize the %vector to the specified
+       *  number of elements.  If the number is smaller than the
+       *  %vector's current size the %vector is truncated, otherwise
+       *  default constructed elements are appended.
+       */
+      void
+      resize(size_type __new_size)
+      {
+       if (__new_size > size())
+         _M_default_append(__new_size - size());
+       else if (__new_size < size())
+         _M_erase_at_end(this->_M_impl._M_start + __new_size);
+      }
+
       /**
        *  @brief  Resizes the %vector to the specified number of elements.
        *  @param  new_size  Number of elements the %vector should contain.
@@ -550,13 +604,34 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
        *  given data.
        */
       void
-      resize(size_type __new_size, value_type __x = value_type())
+      resize(size_type __new_size, const value_type& __x)
       {
-       if (__new_size < size())
+       if (__new_size > size())
+         insert(end(), __new_size - size(), __x);
+       else if (__new_size < size())
          _M_erase_at_end(this->_M_impl._M_start + __new_size);
-       else
+      }
+#else
+      /**
+       *  @brief  Resizes the %vector to the specified number of elements.
+       *  @param  new_size  Number of elements the %vector should contain.
+       *  @param  x  Data with which new elements should be populated.
+       *
+       *  This function will %resize the %vector to the specified
+       *  number of elements.  If the number is smaller than the
+       *  %vector's current size the %vector is truncated, otherwise
+       *  the %vector is extended and new elements are populated with
+       *  given data.
+       */
+      void
+      resize(size_type __new_size, value_type __x = value_type())
+      {
+       if (__new_size > size())
          insert(end(), __new_size - size(), __x);
+       else if (__new_size < size())
+         _M_erase_at_end(this->_M_impl._M_start + __new_size);
       }
+#endif
 
 #ifdef __GXX_EXPERIMENTAL_CXX0X__
       /**  A non-binding request to reduce capacity() to size().  */
@@ -1049,6 +1124,16 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
        this->_M_impl._M_finish = this->_M_impl._M_end_of_storage;
       }
 
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+      // Called by the vector(n) constructor.
+      void
+      _M_default_initialize(size_type __n)
+      {
+       std::__uninitialized_default_n_a(this->_M_impl._M_start, __n, 
+                                        _M_get_Tp_allocator());
+       this->_M_impl._M_finish = this->_M_impl._M_end_of_storage;
+      }
+#endif
 
       // Internal assign functions follow.  The *_aux functions do the actual
       // assignment work for the range versions.
@@ -1131,6 +1216,12 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
       void
       _M_fill_insert(iterator __pos, size_type __n, const value_type& __x);
 
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+      // Called by resize(n).
+      void
+      _M_default_append(size_type __n);
+#endif
+
       // Called by insert(p,x)
 #ifndef __GXX_EXPERIMENTAL_CXX0X__
       void
index e10979310489c40deaee2898535c6c780ac2d607..846a0645d5789b4c639ab022867ee3ae715526cf 100644 (file)
@@ -458,6 +458,59 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
        }
     }
 
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+  template<typename _Tp, typename _Alloc>
+    void
+    vector<_Tp, _Alloc>::
+    _M_default_append(size_type __n)
+    {
+      if (__n != 0)
+       {
+         if (size_type(this->_M_impl._M_end_of_storage
+                       - this->_M_impl._M_finish) >= __n)
+           {
+             std::__uninitialized_default_n_a(this->_M_impl._M_finish,
+                                              __n, _M_get_Tp_allocator());
+             this->_M_impl._M_finish += __n;
+           }
+         else
+           {
+             const size_type __len =
+               _M_check_len(__n, "vector::_M_default_append");
+             const size_type __old_size = this->size();
+             pointer __new_start(this->_M_allocate(__len));
+             pointer __new_finish(__new_start);
+             __try
+               {
+                 __new_finish =
+                   std::__uninitialized_move_a(this->_M_impl._M_start,
+                                               this->_M_impl._M_finish,
+                                               __new_start,
+                                               _M_get_Tp_allocator());
+                 std::__uninitialized_default_n_a(__new_finish, __n,
+                                                  _M_get_Tp_allocator());
+                 __new_finish += __n;
+               }
+             __catch(...)
+               {
+                 std::_Destroy(__new_start, __new_finish,
+                               _M_get_Tp_allocator());
+                 _M_deallocate(__new_start, __len);
+                 __throw_exception_again;
+               }
+             std::_Destroy(this->_M_impl._M_start, this->_M_impl._M_finish,
+                           _M_get_Tp_allocator());
+             _M_deallocate(this->_M_impl._M_start,
+                           this->_M_impl._M_end_of_storage
+                           - this->_M_impl._M_start);
+             this->_M_impl._M_start = __new_start;
+             this->_M_impl._M_finish = __new_finish;
+             this->_M_impl._M_end_of_storage = __new_start + __len;
+           }
+       }
+    }
+#endif
+
   template<typename _Tp, typename _Alloc>
     template<typename _InputIterator>
       void
index 0c98006badb0fc7e0da09e197628ad60195c0588..31f708a9c9d5bbb26f845b8f8f53e9f34ef985e1 100644 (file)
@@ -67,12 +67,24 @@ namespace __debug
       typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
 
       // 23.2.1.1 construct/copy/destroy:
-      explicit deque(const _Allocator& __a = _Allocator())
+      explicit
+      deque(const _Allocator& __a = _Allocator())
       : _Base(__a) { }
 
-      explicit deque(size_type __n, const _Tp& __value = _Tp(),
-                    const _Allocator& __a = _Allocator())
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+      explicit
+      deque(size_type __n)
+      : _Base(__n) { }
+
+      deque(size_type __n, const _Tp& __value,
+           const _Allocator& __a = _Allocator())
+      : _Base(__n, __value, __a) { }
+#else
+      explicit
+      deque(size_type __n, const _Tp& __value = _Tp(),
+           const _Allocator& __a = _Allocator())
       : _Base(__n, __value, __a) { }
+#endif
 
       template<class _InputIterator>
         deque(_InputIterator __first, _InputIterator __last,
@@ -208,6 +220,39 @@ namespace __debug
       using _Base::size;
       using _Base::max_size;
 
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+      void
+      resize(size_type __sz)
+      {
+       typedef typename _Base::const_iterator _Base_const_iterator;
+       typedef __gnu_debug::_After_nth_from<_Base_const_iterator> _After_nth;
+
+       bool __invalidate_all = __sz > this->size();
+       if (__sz < this->size())
+         this->_M_invalidate_if(_After_nth(__sz, _M_base().begin()));
+
+       _Base::resize(__sz);
+
+       if (__invalidate_all)
+         this->_M_invalidate_all();
+      }
+
+      void
+      resize(size_type __sz, const _Tp& __c)
+      {
+       typedef typename _Base::const_iterator _Base_const_iterator;
+       typedef __gnu_debug::_After_nth_from<_Base_const_iterator> _After_nth;
+
+       bool __invalidate_all = __sz > this->size();
+       if (__sz < this->size())
+         this->_M_invalidate_if(_After_nth(__sz, _M_base().begin()));
+
+       _Base::resize(__sz, __c);
+
+       if (__invalidate_all)
+         this->_M_invalidate_all();
+      }
+#else
       void
       resize(size_type __sz, _Tp __c = _Tp())
       {
@@ -223,6 +268,7 @@ namespace __debug
        if (__invalidate_all)
          this->_M_invalidate_all();
       }
+#endif
 
 #ifdef __GXX_EXPERIMENTAL_CXX0X__
       using _Base::shrink_to_fit;
index 39a648188304d33517d32595d269896481ad78a7..c65ed5829f2464286be27c52cc1e9e0a495751c7 100644 (file)
@@ -67,12 +67,24 @@ namespace __debug
       typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
 
       // 23.2.2.1 construct/copy/destroy:
-      explicit list(const _Allocator& __a = _Allocator())
+      explicit
+      list(const _Allocator& __a = _Allocator())
       : _Base(__a) { }
 
-      explicit list(size_type __n, const _Tp& __value = _Tp(),
-                   const _Allocator& __a = _Allocator())
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+      explicit
+      list(size_type __n)
+      : _Base(__n) { }
+
+      list(size_type __n, const _Tp& __value,
+          const _Allocator& __a = _Allocator())
+      : _Base(__n, __value, __a) { }
+#else
+      explicit
+      list(size_type __n, const _Tp& __value = _Tp(),
+          const _Allocator& __a = _Allocator())
       : _Base(__n, __value, __a) { }
+#endif
 
       template<class _InputIterator>
       list(_InputIterator __first, _InputIterator __last,
@@ -208,6 +220,63 @@ namespace __debug
       using _Base::size;
       using _Base::max_size;
 
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+      void
+      resize(size_type __sz)
+      {
+       this->_M_detach_singular();
+
+       // if __sz < size(), invalidate all iterators in [begin+__sz, end())
+       iterator __victim = begin();
+       iterator __end = end();
+       for (size_type __i = __sz; __victim != __end && __i > 0; --__i)
+         ++__victim;
+
+       while (__victim != __end)
+         {
+           iterator __real_victim = __victim++;
+           __real_victim._M_invalidate();
+         }
+
+       __try
+         {
+           _Base::resize(__sz);
+         }
+       __catch(...)
+         {
+           this->_M_revalidate_singular();
+           __throw_exception_again;
+         }
+      }
+
+      void
+      resize(size_type __sz, const _Tp& __c)
+      {
+       this->_M_detach_singular();
+
+       // if __sz < size(), invalidate all iterators in [begin+__sz, end())
+       iterator __victim = begin();
+       iterator __end = end();
+       for (size_type __i = __sz; __victim != __end && __i > 0; --__i)
+         ++__victim;
+
+       while (__victim != __end)
+         {
+           iterator __real_victim = __victim++;
+           __real_victim._M_invalidate();
+         }
+
+       __try
+         {
+           _Base::resize(__sz, __c);
+         }
+       __catch(...)
+         {
+           this->_M_revalidate_singular();
+           __throw_exception_again;
+         }
+      }
+#else
       void
       resize(size_type __sz, _Tp __c = _Tp())
       {
@@ -235,6 +304,7 @@ namespace __debug
            __throw_exception_again;
          }
       }
+#endif
 
       // element access:
       reference
index ea55b080442a53d818f11e68214fb24430664303..c81f956212e77b99f7246ac77c2c956e64c7886e 100644 (file)
@@ -72,12 +72,24 @@ namespace __debug
       typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
 
       // 23.2.4.1 construct/copy/destroy:
-      explicit vector(const _Allocator& __a = _Allocator())
+      explicit
+      vector(const _Allocator& __a = _Allocator())
       : _Base(__a), _M_guaranteed_capacity(0) { }
 
-      explicit vector(size_type __n, const _Tp& __value = _Tp(),
-                     const _Allocator& __a = _Allocator())
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+      explicit
+      vector(size_type __n)
+      : _Base(__n), _M_guaranteed_capacity(__n) { }
+
+      vector(size_type __n, const _Tp& __value,
+            const _Allocator& __a = _Allocator())
+      : _Base(__n, __value, __a), _M_guaranteed_capacity(__n) { }
+#else
+      explicit
+      vector(size_type __n, const _Tp& __value = _Tp(),
+            const _Allocator& __a = _Allocator())
       : _Base(__n, __value, __a), _M_guaranteed_capacity(__n) { }
+#endif
 
       template<class _InputIterator>
         vector(_InputIterator __first, _InputIterator __last,
@@ -226,6 +238,31 @@ namespace __debug
       using _Base::size;
       using _Base::max_size;
 
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+      void
+      resize(size_type __sz)
+      {
+       bool __realloc = _M_requires_reallocation(__sz);
+       if (__sz < this->size())
+         this->_M_invalidate_if(_After_nth(__sz, _M_base().begin()));
+       _Base::resize(__sz);
+       if (__realloc)
+         this->_M_invalidate_all();
+       _M_update_guaranteed_capacity();
+      }
+
+      void
+      resize(size_type __sz, const _Tp& __c)
+      {
+       bool __realloc = _M_requires_reallocation(__sz);
+       if (__sz < this->size())
+         this->_M_invalidate_if(_After_nth(__sz, _M_base().begin()));
+       _Base::resize(__sz, __c);
+       if (__realloc)
+         this->_M_invalidate_all();
+       _M_update_guaranteed_capacity();
+      }
+#else
       void
       resize(size_type __sz, _Tp __c = _Tp())
       {
@@ -237,6 +274,7 @@ namespace __debug
          this->_M_invalidate_all();
        _M_update_guaranteed_capacity();
       }
+#endif
 
 #ifdef __GXX_EXPERIMENTAL_CXX0X__
       using _Base::shrink_to_fit;
index 55e8d49d68674d5c481e8efebde0afbf1268a73b..9f8ce70c9dbbdeb0b74957a35010f0f1d3156c05 100644 (file)
@@ -60,12 +60,24 @@ namespace __profile
       typedef typename _Base::const_pointer         const_pointer;
 
       // 23.2.1.1 construct/copy/destroy:
-      explicit deque(const _Allocator& __a = _Allocator())
+      explicit
+      deque(const _Allocator& __a = _Allocator())
       : _Base(__a) { }
 
-      explicit deque(size_type __n, const _Tp& __value = _Tp(),
-                    const _Allocator& __a = _Allocator())
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+      explicit
+      deque(size_type __n)
+      : _Base(__n) { }
+
+      deque(size_type __n, const _Tp& __value,
+           const _Allocator& __a = _Allocator())
       : _Base(__n, __value, __a) { }
+#else
+      explicit
+      deque(size_type __n, const _Tp& __value = _Tp(),
+           const _Allocator& __a = _Allocator())
+      : _Base(__n, __value, __a) { }
+#endif
 
       template<class _InputIterator>
         deque(_InputIterator __first, _InputIterator __last,
@@ -195,11 +207,25 @@ namespace __profile
       using _Base::size;
       using _Base::max_size;
 
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+      void
+      resize(size_type __sz)
+      {
+       _Base::resize(__sz);
+      }
+
+      void
+      resize(size_type __sz, const _Tp& __c)
+      {
+       _Base::resize(__sz, __c);
+      }
+#else
       void
       resize(size_type __sz, _Tp __c = _Tp())
       {
        _Base::resize(__sz, __c);
       }
+#endif
 
 #ifdef __GXX_EXPERIMENTAL_CXX0X__
       using _Base::shrink_to_fit;
index 01edd2919f67a9bdb6abb1c8b78e7b90982f8f95..e5468c440710bcb5976e99871d7a3e32104372c1 100644 (file)
@@ -64,20 +64,40 @@ template<typename _Tp, typename _Allocator = std::allocator<_Tp> >
       typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
 
       // 23.2.2.1 construct/copy/destroy:
-      explicit list(const _Allocator& __a = _Allocator())
+      explicit
+      list(const _Allocator& __a = _Allocator())
       : _Base(__a) 
       { 
         __profcxx_list_construct(this);        // list2slist
         __profcxx_list_construct2(this);       // list2vector
       }
 
-      explicit list(size_type __n, const _Tp& __value = _Tp(),
-                   const _Allocator& __a = _Allocator())
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+      explicit
+      list(size_type __n)
+      : _Base(__n) 
+      { 
+        __profcxx_list_construct(this); 
+        __profcxx_list_construct2(this); 
+      }
+
+      list(size_type __n, const _Tp& __value,
+          const _Allocator& __a = _Allocator())
+      : _Base(__n, __value, __a) 
+      { 
+        __profcxx_list_construct(this); 
+        __profcxx_list_construct2(this); 
+      }
+#else
+      explicit
+      list(size_type __n, const _Tp& __value = _Tp(),
+          const _Allocator& __a = _Allocator())
       : _Base(__n, __value, __a) 
       { 
         __profcxx_list_construct(this); 
         __profcxx_list_construct2(this); 
       }
+#endif
 
       template<class _InputIterator>
       list(_InputIterator __first, _InputIterator __last,
@@ -229,9 +249,19 @@ template<typename _Tp, typename _Allocator = std::allocator<_Tp> >
       using _Base::size;
       using _Base::max_size;
 
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+      void
+      resize(size_type __sz)
+      { _Base::resize(__sz); }
+
+      void
+      resize(size_type __sz, const _Tp& __c)
+      { _Base::resize(__sz, __c); }
+#else
       void
       resize(size_type __sz, _Tp __c = _Tp())
       { _Base::resize(__sz, __c); }
+#endif
 
       // element access:
       reference
index ad74137583c92d62ec5ea2a58d14f1c4dba24abf..e6c32a38aec31e81ebfd516322b928ebebc6ca62 100644 (file)
@@ -76,20 +76,40 @@ namespace __profile
       _M_base() const { return *this; }
 
       // 23.2.4.1 construct/copy/destroy:
-      explicit vector(const _Allocator& __a = _Allocator())
+      explicit
+      vector(const _Allocator& __a = _Allocator())
       : _Base(__a)
       { 
         __profcxx_vector_construct(this, this->capacity());
         __profcxx_vector_construct2(this);
       }
 
-      explicit vector(size_type __n, const _Tp& __value = _Tp(),
-                     const _Allocator& __a = _Allocator())
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+      explicit
+      vector(size_type __n)
+      :  _Base(__n)
+      { 
+        __profcxx_vector_construct(this, this->capacity());
+        __profcxx_vector_construct2(this);
+      }
+
+      vector(size_type __n, const _Tp& __value,
+            const _Allocator& __a = _Allocator())
       :  _Base(__n, __value, __a)
       { 
         __profcxx_vector_construct(this, this->capacity());
         __profcxx_vector_construct2(this);
       }
+#else
+      explicit
+      vector(size_type __n, const _Tp& __value = _Tp(),
+            const _Allocator& __a = _Allocator())
+      :  _Base(__n, __value, __a)
+      { 
+        __profcxx_vector_construct(this, this->capacity());
+        __profcxx_vector_construct2(this);
+      }
+#endif
 
       template<class _InputIterator>
         vector(_InputIterator __first, _InputIterator __last,
@@ -218,6 +238,23 @@ namespace __profile
       using _Base::size;
       using _Base::max_size;
 
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+      void
+      resize(size_type __sz)
+      {
+        __profcxx_vector_invalid_operator(this);
+        _M_profile_resize(this, this->capacity(), __sz);
+        _Base::resize(__sz);
+      }
+
+      void
+      resize(size_type __sz, const _Tp& __c)
+      {
+        __profcxx_vector_invalid_operator(this);
+        _M_profile_resize(this, this->capacity(), __sz);
+        _Base::resize(__sz, __c);
+      }
+#else
       void
       resize(size_type __sz, _Tp __c = _Tp())
       {
@@ -225,6 +262,7 @@ namespace __profile
         _M_profile_resize(this, this->capacity(), __sz);
         _Base::resize(__sz, __c);
       }
+#endif
 
 #ifdef __GXX_EXPERIMENTAL_CXX0X__
       using _Base::shrink_to_fit;
index 089b10b83a61a01e6f3adb695755f7da26084545..475880888cc238dcc7a338d1b3091f33fe91abfc 100644 (file)
@@ -1,6 +1,6 @@
 // { dg-options "-std=gnu++0x" }
 
-// Copyright (C) 2005, 2006, 2007, 2009 Free Software Foundation, Inc.
+// Copyright (C) 2005, 2006, 2007, 2009, 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
 // with this library; see the file COPYING3.  If not see
 // <http://www.gnu.org/licenses/>.
 
-
 #include <deque>
 #include <testsuite_hooks.h>
 #include <testsuite_rvalref.h>
 
 using namespace __gnu_test;
 
-// According to n1771, there should be two resizes, with and without
-// parameter. We only have one at present, whose second parameter defaults
-// to a default-constructed object.
 void
 test01()
 {
@@ -38,30 +34,17 @@ test01()
   a.resize(98);
   a.resize(99);
   a.resize(100);
-#if ! defined _GLIBCXX_DEBUG && ! defined _GLIBCXX_PROFILE
-  VERIFY( copycounter::copycount == 100 );
-#else
-  VERIFY( copycounter::copycount == 100 + 4 );
-#endif
+  VERIFY( copycounter::copycount == 0 );
+
   a.resize(99);
   a.resize(0);
-#if ! defined _GLIBCXX_DEBUG && ! defined _GLIBCXX_PROFILE
-  VERIFY( copycounter::copycount == 100 );
-#else
-  VERIFY( copycounter::copycount == 100 + 6 );
-#endif
+  VERIFY( copycounter::copycount == 0 );
+
   a.resize(100);
-#if ! defined _GLIBCXX_DEBUG && ! defined _GLIBCXX_PROFILE
-  VERIFY( copycounter::copycount == 200 );
-#else
-  VERIFY( copycounter::copycount == 200 + 7 );
-#endif
+  VERIFY( copycounter::copycount == 0 );
+
   a.clear();
-#if ! defined _GLIBCXX_DEBUG && ! defined _GLIBCXX_PROFILE
-  VERIFY( copycounter::copycount == 200 );
-#else
-  VERIFY( copycounter::copycount == 200 + 7 );
-#endif
+  VERIFY( copycounter::copycount == 0 );
 }
 
 
diff --git a/libstdc++-v3/testsuite/23_containers/deque/capacity/resize_size.cc b/libstdc++-v3/testsuite/23_containers/deque/capacity/resize_size.cc
new file mode 100644 (file)
index 0000000..229a0eb
--- /dev/null
@@ -0,0 +1,43 @@
+// { dg-options "-std=gnu++0x" }
+
+// 2010-06-18  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 <deque>
+#include <testsuite_hooks.h>
+#include <testsuite_api.h>
+
+void test01()
+{
+  bool test __attribute__((unused)) = true;
+
+  std::deque<__gnu_test::NonCopyConstructible> d;
+  VERIFY( std::distance(d.begin(), d.end()) == 0 );
+
+  d.resize(1000);
+  VERIFY( std::distance(d.begin(), d.end()) == 1000 );
+  for(auto it = d.begin(); it != d.end(); ++it)
+    VERIFY( *it == -1 );
+}
+
+int main()
+{
+  test01();
+  return 0;
+}
diff --git a/libstdc++-v3/testsuite/23_containers/deque/cons/cons_size.cc b/libstdc++-v3/testsuite/23_containers/deque/cons/cons_size.cc
new file mode 100644 (file)
index 0000000..0207fd7
--- /dev/null
@@ -0,0 +1,40 @@
+// { dg-options "-std=gnu++0x" }
+
+// 2010-06-18  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 <deque>
+#include <testsuite_hooks.h>
+#include <testsuite_api.h>
+
+void test01()
+{
+  bool test __attribute__((unused)) = true;
+
+  std::deque<__gnu_test::NonCopyConstructible> d(1000);
+  VERIFY( std::distance(d.begin(), d.end()) == 1000 );
+  for(auto it = d.begin(); it != d.end(); ++it)
+    VERIFY( *it == -1 );
+}
+
+int main()
+{
+  test01();
+  return 0;
+}
index 96be31cb62af3745b8e9755ad041018ec1bd4ba8..bd6ee6363051eaf0f0f56984ad2d2f4d9ed280b9 100644 (file)
@@ -18,7 +18,7 @@
 // <http://www.gnu.org/licenses/>.
 
 // { dg-do compile }
-// { dg-error "no matching" "" { target *-*-* } 1577 }
+// { dg-error "no matching" "" { target *-*-* } 1659 }
 // { dg-excess-errors "" }
 
 #include <deque>
index 59d4e2f4158daa064303eaa3f48c1c1014eceb6a..21c9d4e4f3c990a4f63f36520f81494192e37174 100644 (file)
@@ -18,7 +18,7 @@
 // <http://www.gnu.org/licenses/>.
 
 // { dg-do compile }
-// { dg-error "no matching" "" { target *-*-* } 1516 }
+// { dg-error "no matching" "" { target *-*-* } 1592 }
 // { dg-excess-errors "" }
 
 #include <deque>
index 6208581b87753ae0aa773b66ccf963214216305a..08f54d68018708e8ddeafe41440efeaa9f9fa184 100644 (file)
@@ -1,6 +1,6 @@
 // 2007-04-27  Paolo Carlini  <pcarlini@suse.de>
 
-// Copyright (C) 2007, 2008, 2009 Free Software Foundation
+// Copyright (C) 2007, 2008, 2009, 2010 Free Software Foundation
 //
 // 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
@@ -18,7 +18,7 @@
 // <http://www.gnu.org/licenses/>.
 
 // { dg-do compile }
-// { dg-error "no matching" "" { target *-*-* } 1516 }
+// { dg-error "no matching" "" { target *-*-* } 1592 }
 // { dg-excess-errors "" }
 
 #include <deque>
index 7fb2479d02cce8052bf00070a841f1e6d647c40f..a5bd6065c1c94e505a1b269e4f807181011a1dbd 100644 (file)
@@ -18,7 +18,7 @@
 // <http://www.gnu.org/licenses/>.
 
 // { dg-do compile }
-// { dg-error "no matching" "" { target *-*-* } 1661 }
+// { dg-error "no matching" "" { target *-*-* } 1743 }
 // { dg-excess-errors "" }
 
 #include <deque>
similarity index 79%
rename from libstdc++-v3/testsuite/23_containers/forward_list/cons/10.cc
rename to libstdc++-v3/testsuite/23_containers/forward_list/capacity/resize_size.cc
index 4e599dab6bcd9e70c42033fec66d56b08b4b0a2b..e22af3cbc1938826ded35a13554bbedf35dd20e5 100644 (file)
 
 #include <forward_list>
 #include <testsuite_hooks.h>
-
-struct NoCopyConstructor
-{
-  NoCopyConstructor() : num(-1) { }
-  NoCopyConstructor(const NoCopyConstructor&) = delete;
-
-  operator int() { return num; }
-
-private:
-  int num;
-};
+#include <testsuite_api.h>
 
 void test01()
 {
   bool test __attribute__((unused)) = true;
 
-  std::forward_list<NoCopyConstructor> fl(5);
-  VERIFY( std::distance(fl.begin(), fl.end()) == 5 );
+  std::forward_list<__gnu_test::NonCopyConstructible> fl;
+  VERIFY( std::distance(fl.begin(), fl.end()) == 0 );
+
+  fl.resize(1000);
+  VERIFY( std::distance(fl.begin(), fl.end()) == 1000 );
   for(auto it = fl.begin(); it != fl.end(); ++it)
     VERIFY( *it == -1 );
 }
similarity index 75%
rename from libstdc++-v3/testsuite/23_containers/forward_list/modifiers/6.cc
rename to libstdc++-v3/testsuite/23_containers/forward_list/cons/cons_size.cc
index 985f592e6028c6bb660c77d6a249b34605bb503f..3d07f67208956ba4dc7a0dba26451f2f603e657e 100644 (file)
 
 #include <forward_list>
 #include <testsuite_hooks.h>
-
-struct NoCopyConstructor
-{
-  NoCopyConstructor() : num(-1) { }
-  NoCopyConstructor(const NoCopyConstructor&) = delete;
-
-  operator int() { return num; }
-
-private:
-  int num;
-};
+#include <testsuite_api.h>
 
 void test01()
 {
   bool test __attribute__((unused)) = true;
 
-  std::forward_list<NoCopyConstructor> fl;
-  VERIFY( std::distance(fl.begin(), fl.end()) == 0 );
-
-  fl.resize(10);
-  VERIFY( std::distance(fl.begin(), fl.end()) == 10 );
+  std::forward_list<__gnu_test::NonCopyConstructible> fl(1000);
+  VERIFY( std::distance(fl.begin(), fl.end()) == 1000 );
   for(auto it = fl.begin(); it != fl.end(); ++it)
     VERIFY( *it == -1 );
 }
index 1625e3bc76bef850529f310a5527a73581938429..aa0f3e07def8612f4a602d3f274f80457364b79c 100644 (file)
@@ -1,6 +1,6 @@
 // { dg-do compile }
 // { dg-options "-std=gnu++0x" }
-// { dg-error "no matching" "" { target *-*-* } 1196 }
+// { dg-error "no matching" "" { target *-*-* } 1198 }
 // { dg-excess-errors "" }
 
 // Copyright (C) 2009, 2010 Free Software Foundation
index 5acfcd1f47f6908cacbc7721d6dc364d94d4db48..3975b0516111f359bd344bcc76047a1aed6b84c5 100644 (file)
@@ -1,6 +1,6 @@
 // { dg-do compile }
 // { dg-options "-std=gnu++0x" }
-// { dg-error "no matching" "" { target *-*-* } 1196 }
+// { dg-error "no matching" "" { target *-*-* } 1198 }
 // { dg-excess-errors "" }
 
 // Copyright (C) 2009, 2010 Free Software Foundation
index dcf69089b004a4b60ca342955cf4af7069d4b454..0b0471c8cc981f96de75ecec50389b662c232e5d 100644 (file)
@@ -1,6 +1,6 @@
 // { dg-do compile }
 // { dg-options "-std=gnu++0x" }
-// { dg-error "no matching" "" { target *-*-* } 1196 }
+// { dg-error "no matching" "" { target *-*-* } 1198 }
 // { dg-excess-errors "" }
 
 // Copyright (C) 2009, 2010 Free Software Foundation
index 22574fd081a16d5c413e4623aeb6d4a49869d027..849eb643e87bf4d300ea37ca9fdc8d0ed0276fb1 100644 (file)
@@ -1,6 +1,6 @@
 // { dg-do compile }
 // { dg-options "-std=gnu++0x" }
-// { dg-error "no matching" "" { target *-*-* } 1196 }
+// { dg-error "no matching" "" { target *-*-* } 1198 }
 // { dg-excess-errors "" }
 
 // Copyright (C) 2009, 2010 Free Software Foundation
diff --git a/libstdc++-v3/testsuite/23_containers/list/capacity/resize_size.cc b/libstdc++-v3/testsuite/23_containers/list/capacity/resize_size.cc
new file mode 100644 (file)
index 0000000..06424c0
--- /dev/null
@@ -0,0 +1,43 @@
+// { dg-options "-std=gnu++0x" }
+
+// 2010-06-18  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 <list>
+#include <testsuite_hooks.h>
+#include <testsuite_api.h>
+
+void test01()
+{
+  bool test __attribute__((unused)) = true;
+
+  std::list<__gnu_test::NonCopyConstructible> l;
+  VERIFY( std::distance(l.begin(), l.end()) == 0 );
+
+  l.resize(1000);
+  VERIFY( std::distance(l.begin(), l.end()) == 1000 );
+  for(auto it = l.begin(); it != l.end(); ++it)
+    VERIFY( *it == -1 );
+}
+
+int main()
+{
+  test01();
+  return 0;
+}
diff --git a/libstdc++-v3/testsuite/23_containers/list/cons/cons_size.cc b/libstdc++-v3/testsuite/23_containers/list/cons/cons_size.cc
new file mode 100644 (file)
index 0000000..f59f520
--- /dev/null
@@ -0,0 +1,40 @@
+// { dg-options "-std=gnu++0x" }
+
+// 2010-06-18  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 <list>
+#include <testsuite_hooks.h>
+#include <testsuite_api.h>
+
+void test01()
+{
+  bool test __attribute__((unused)) = true;
+
+  std::list<__gnu_test::NonCopyConstructible> l(1000);
+  VERIFY( std::distance(l.begin(), l.end()) == 1000 );
+  for(auto it = l.begin(); it != l.end(); ++it)
+    VERIFY( *it == -1 );
+}
+
+int main()
+{
+  test01();
+  return 0;
+}
index eb35a24c89d7eab21549b08f5ef50a982bf4ef8c..2446157597fd279a63b116ace67d70a034c65980 100644 (file)
@@ -18,7 +18,7 @@
 // <http://www.gnu.org/licenses/>.
 
 // { dg-do compile }
-// { dg-error "no matching" "" { target *-*-* } 1411 }
+// { dg-error "no matching" "" { target *-*-* } 1478 }
 // { dg-excess-errors "" }
 
 #include <list>
index 937404b26a8c0deb63b89a10198f4288e1d598f8..cbac8e80cbf0ae8e6fa3c54179cfa160f64d0167 100644 (file)
@@ -18,7 +18,7 @@
 // <http://www.gnu.org/licenses/>.
 
 // { dg-do compile }
-// { dg-error "no matching" "" { target *-*-* } 1380 }
+// { dg-error "no matching" "" { target *-*-* } 1434 }
 // { dg-excess-errors "" }
 
 #include <list>
index 74fc1b7a1630299ec1a5ed9a340452cac9b75275..232bd042ddba688a4cfde43bcb902dc377f93afc 100644 (file)
@@ -18,7 +18,7 @@
 // <http://www.gnu.org/licenses/>.
 
 // { dg-do compile }
-// { dg-error "no matching" "" { target *-*-* } 1380 }
+// { dg-error "no matching" "" { target *-*-* } 1434 }
 // { dg-excess-errors "" }
 
 #include <list>
index 3aebda5ddb2af7464da6904378ccacc3f7a086ab..aefb1f583fd69a931ae2d02efa28f28fcfacfd1e 100644 (file)
@@ -18,7 +18,7 @@
 // <http://www.gnu.org/licenses/>.
 
 // { dg-do compile }
-// { dg-error "no matching" "" { target *-*-* } 1380 }
+// { dg-error "no matching" "" { target *-*-* } 1434 }
 // { dg-excess-errors "" }
 
 #include <list>
similarity index 50%
rename from libstdc++-v3/testsuite/23_containers/vector/resize/moveable.cc
rename to libstdc++-v3/testsuite/23_containers/vector/capacity/resize/moveable.cc
index 47fdf8fcafa8ac24aae67391c617d60b6a94afb1..5ba026dbeb555494f2650b47063a68f60c551a9d 100644 (file)
@@ -1,6 +1,7 @@
 // { dg-options "-std=gnu++0x" }
 
-// Copyright (C) 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
+// Copyright (C) 2005, 2006, 2007, 2008, 2009, 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
 // with this library; see the file COPYING3.  If not see
 // <http://www.gnu.org/licenses/>.
 
-
 #include <vector>
 #include <testsuite_hooks.h>
 #include <testsuite_rvalref.h>
 
 using namespace __gnu_test;
 
-// According to n1771, there should be two resizes, with and without
-// parameter. We only have one at present, whose second parameter defaults
-// to a default-constructed object.
-// Also, the values are one higher than might be expected because internally
-// resize calls fill, which copies its input value in case it is already in
-// the vector when the vector isn't moved.
 void
 test01()
 {
@@ -41,30 +35,17 @@ test01()
   a.resize(98);
   a.resize(99);
   a.resize(100);
-#if !defined(_GLIBCXX_DEBUG) && !defined(_GLIBCXX_PROFILE)
-  VERIFY( copycounter::copycount == 100 + 1 );
-#else
-  VERIFY( copycounter::copycount == 100 + 1 + 4 );
-#endif
+  VERIFY( copycounter::copycount == 0 );
+
   a.resize(99);
   a.resize(0);
-#if !defined(_GLIBCXX_DEBUG) && !defined(_GLIBCXX_PROFILE)
-  VERIFY( copycounter::copycount == 100 + 1 );
-#else
-  VERIFY( copycounter::copycount == 100 + 1 + 6 );
-#endif
+  VERIFY( copycounter::copycount == 0 );
+
   a.resize(100);
-#if !defined(_GLIBCXX_DEBUG) && !defined(_GLIBCXX_PROFILE)
-  VERIFY( copycounter::copycount == 200 + 2 );
-#else
-  VERIFY( copycounter::copycount == 200 + 2 + 7 );
-#endif
+  VERIFY( copycounter::copycount == 0 );
+
   a.clear();
-#if !defined(_GLIBCXX_DEBUG) && !defined(_GLIBCXX_PROFILE)
-  VERIFY( copycounter::copycount == 200 + 2 );
-#else
-  VERIFY( copycounter::copycount == 200 + 2 + 7 );
-#endif
+  VERIFY( copycounter::copycount == 0 );
 }
 
 
diff --git a/libstdc++-v3/testsuite/23_containers/vector/capacity/resize/resize_size.cc b/libstdc++-v3/testsuite/23_containers/vector/capacity/resize/resize_size.cc
new file mode 100644 (file)
index 0000000..d181168
--- /dev/null
@@ -0,0 +1,43 @@
+// { dg-options "-std=gnu++0x" }
+
+// 2010-06-18  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 <vector>
+#include <testsuite_hooks.h>
+#include <testsuite_api.h>
+
+void test01()
+{
+  bool test __attribute__((unused)) = true;
+
+  std::vector<__gnu_test::NonCopyConstructible> v;
+  VERIFY( std::distance(v.begin(), v.end()) == 0 );
+
+  v.resize(1000);
+  VERIFY( std::distance(v.begin(), v.end()) == 1000 );
+  for(auto it = v.begin(); it != v.end(); ++it)
+    VERIFY( *it == -1 );
+}
+
+int main()
+{
+  test01();
+  return 0;
+}
diff --git a/libstdc++-v3/testsuite/23_containers/vector/cons/cons_size.cc b/libstdc++-v3/testsuite/23_containers/vector/cons/cons_size.cc
new file mode 100644 (file)
index 0000000..a33ba1a
--- /dev/null
@@ -0,0 +1,40 @@
+// { dg-options "-std=gnu++0x" }
+
+// 2010-06-18  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 <vector>
+#include <testsuite_hooks.h>
+#include <testsuite_api.h>
+
+void test01()
+{
+  bool test __attribute__((unused)) = true;
+
+  std::vector<__gnu_test::NonCopyConstructible> v(1000);
+  VERIFY( std::distance(v.begin(), v.end()) == 1000 );
+  for(auto it = v.begin(); it != v.end(); ++it)
+    VERIFY( *it == -1 );
+}
+
+int main()
+{
+  test01();
+  return 0;
+}
index b96b5359963b346f02ad219054cfd6529360efbd..6925c1776a44f18a7149d1f255f1f94328dac3a1 100644 (file)
@@ -18,7 +18,7 @@
 // <http://www.gnu.org/licenses/>.
 
 // { dg-do compile }
-// { dg-error "no matching" "" { target *-*-* } 1063 }
+// { dg-error "no matching" "" { target *-*-* } 1148 }
 // { dg-excess-errors "" }
 
 #include <vector>
index 950643857c532cf0218a5940057ec752779bfc34..662bf169b2386510bc2fde08db4019d930129d30 100644 (file)
@@ -18,7 +18,7 @@
 // <http://www.gnu.org/licenses/>.
 
 // { dg-do compile }
-// { dg-error "no matching" "" { target *-*-* } 1003 }
+// { dg-error "no matching" "" { target *-*-* } 1078 }
 // { dg-excess-errors "" }
 
 #include <vector>
index f17b541a4e000eac11ebc11090a2f8f65dab459b..fe2a2b25475e9aeadc090b5fcfe60bbd8cecc5f1 100644 (file)
@@ -18,7 +18,7 @@
 // <http://www.gnu.org/licenses/>.
 
 // { dg-do compile }
-// { dg-error "no matching" "" { target *-*-* } 1003 }
+// { dg-error "no matching" "" { target *-*-* } 1078 }
 // { dg-excess-errors "" }
 
 #include <vector>
index 19d3fd08c4b8e5edd5197d85ffeda46ce0187067..9869af131dfaab0a92d6b377a7e671d36e2e58d9 100644 (file)
@@ -18,7 +18,7 @@
 // <http://www.gnu.org/licenses/>.
 
 // { dg-do compile }
-// { dg-error "no matching" "" { target *-*-* } 1104 }
+// { dg-error "no matching" "" { target *-*-* } 1189 }
 // { dg-excess-errors "" }
 
 #include <vector>
index fcb762eff66427a1308796f20bbb44b4a7eeb9a7..11007904093d9db4874207a2d4161a0f77e10bfb 100644 (file)
@@ -19,7 +19,6 @@
 // <http://www.gnu.org/licenses/>.
 //
 
-#include <cstddef>
 #include <exception>
 #include <testsuite_hooks.h>
 
@@ -107,7 +106,7 @@ namespace __gnu_test
   // For 23 unordered_* requirements.
   struct NonDefaultConstructible_hash
   {
-    size_t
+    std::size_t
     operator()(NonDefaultConstructible) const
     { return 1; }
   };
@@ -170,10 +169,29 @@ namespace __gnu_test
 
   struct OverloadedAddress_hash
   {
-    size_t
+    std::size_t
     operator()(const OverloadedAddress&) const
     { return 1; }
   };
+
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+  struct NonCopyConstructible
+  {
+    NonCopyConstructible() : num(-1) { }
+
+    NonCopyConstructible(NonCopyConstructible&& other)
+    : num(other.num)
+    { other.num = 0; }
+
+    NonCopyConstructible(const NonCopyConstructible&) = delete;
+
+    operator int() { return num; }
+
+  private:
+    int num;
+  };
+#endif
+
 }
 
 #endif