allocator.h (__shrink_to_fit): Simplify.
authorPaolo Carlini <paolo@gcc.gnu.org>
Wed, 8 Jun 2011 11:07:24 +0000 (11:07 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Wed, 8 Jun 2011 11:07:24 +0000 (11:07 +0000)
2011-06-08  Paolo Carlini  <paolo.carlini@oracle.com>

* include/bits/allocator.h (__shrink_to_fit): Simplify.
* include/bits/stl_vector.h (vector<>::shrink_to_fit): Adjust.
* include/bits/stl_deque.h: Likewise.
* include/bits/stl_bvector.h: Likewise.

From-SVN: r174802

libstdc++-v3/ChangeLog
libstdc++-v3/include/bits/allocator.h
libstdc++-v3/include/bits/stl_bvector.h
libstdc++-v3/include/bits/stl_deque.h
libstdc++-v3/include/bits/stl_vector.h

index b259e9a97827abaedc4289d053f017041f3865a9..e456f59646930eeb949f741976cd1e37e921d603 100644 (file)
@@ -1,3 +1,10 @@
+2011-06-08  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       * include/bits/allocator.h (__shrink_to_fit): Simplify.
+       * include/bits/stl_vector.h (vector<>::shrink_to_fit): Adjust.
+       * include/bits/stl_deque.h: Likewise.
+       * include/bits/stl_bvector.h: Likewise.
+
 2011-06-07  Jason Merrill  <jason@redhat.com>
 
        * testsuite/lib/prune.exp: s/required/instantiated/.
@@ -7,7 +14,8 @@
        * testsuite/20_util/duration/requirements/typedefs_neg3.cc: Likewise.
        * testsuite/20_util/forward/1_neg.cc: Likewise.
        * testsuite/20_util/make_signed/requirements/typedefs_neg.cc: Likewise.
-       * testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc: Likewise.
+       * testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc:
+       Likewise.
        * testsuite/20_util/ratio/cons/cons_overflow_neg.cc: Likewise.
        * testsuite/20_util/ratio/operations/ops_overflow_neg.cc: Likewise.
        * testsuite/20_util/shared_ptr/assign/shared_ptr_neg.cc: Likewise.
@@ -17,7 +25,8 @@
        * testsuite/ext/type_traits/add_unsigned_integer_neg.cc: Likewise.
        * testsuite/ext/type_traits/remove_unsigned_floating_neg.cc: Likewise.
        * testsuite/ext/type_traits/remove_unsigned_integer_neg.cc: Likewise.
-       * testsuite/tr1/2_general_utilities/shared_ptr/assign/shared_ptr_neg.cc: Likewise.
+       * testsuite/tr1/2_general_utilities/shared_ptr/assign/
+       shared_ptr_neg.cc: Likewise.
 
 2011-06-07  Paolo Carlini  <paolo.carlini@oracle.com>
 
index 6fccba51bb1ec8e7ed7784c3c9a0ac7049787982..4fc14105cd3c1112cd5cc020a6bb7863b3e1abe6 100644 (file)
@@ -184,28 +184,18 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     };
 
 #ifdef __GXX_EXPERIMENTAL_CXX0X__
-  // A very basic implementation for now.  In general we have to wait for
-  // the availability of the infrastructure described in N2983:  we should
-  // try when either T has a move constructor which cannot throw or T is
-  // CopyConstructible.
-  // NB: This code doesn't properly belong here, we should find a more
-  // suited place common to std::vector and std::deque.
-  template<typename _Tp,
-          bool = __has_trivial_copy(typename _Tp::value_type)>
-    struct __shrink_to_fit
-    { static void _S_do_it(_Tp&) { } };
-
   template<typename _Tp>
-    struct __shrink_to_fit<_Tp, true>
+    bool
+    __shrink_to_fit(_Tp& __v)
     {
-      static void
-      _S_do_it(_Tp& __v)
-      {
-       __try
-         { _Tp(__v).swap(__v); }
-       __catch(...) { }
-      }
-    };
+      __try
+       {
+         _Tp(__v).swap(__v);
+         return true;
+       }
+      __catch(...)
+       { return false; }
+    }
 
   template<typename _Alloc, typename _Tp>
     class __alloctr_rebind_helper
index edf662987cb7852b75574d8e15dba7b1d7aa03a9..30e7b2d9675d43db8c884e53c04bf788a1cccfce 100644 (file)
@@ -844,7 +844,7 @@ template<typename _Alloc>
 #ifdef __GXX_EXPERIMENTAL_CXX0X__
     void
     shrink_to_fit()
-    { std::__shrink_to_fit<vector>::_S_do_it(*this); }
+    { std::__shrink_to_fit(*this); }
 #endif
 
     void
index 7ddfbc5ac16846376caa0a5ef1533a0638e5efc7..fab63f130c8d887d611ced6531b449a575ee2468 100644 (file)
@@ -1196,7 +1196,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
       /**  A non-binding request to reduce memory use.  */
       void
       shrink_to_fit()
-      { std::__shrink_to_fit<deque>::_S_do_it(*this); }
+      { std::__shrink_to_fit(*this); }
 #endif
 
       /**
index 5fa5f522e0c9f89bf0db77824f105d14a32293a1..4f617861e8f3374b0174a4c5d28e3feef34531ba 100644 (file)
@@ -646,7 +646,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
       /**  A non-binding request to reduce capacity() to size().  */
       void
       shrink_to_fit()
-      { std::__shrink_to_fit<vector>::_S_do_it(*this); }
+      { std::__shrink_to_fit(*this); }
 #endif
 
       /**