diff options
author | Paolo Carlini <paolo@gcc.gnu.org> | 2011-06-08 11:07:24 +0000 |
---|---|---|
committer | Paolo Carlini <paolo@gcc.gnu.org> | 2011-06-08 11:07:24 +0000 |
commit | 76aa78e9eb7ade737abc19cbea1bcd690170b039 (patch) | |
tree | 13e6b3a72d25efb2390fe71ac59d916d84cffcca | |
parent | 6c8e9fc9e83e3a5d28705bc5460917f62a3f5a28 (diff) | |
download | gcc-76aa78e9eb7ade737abc19cbea1bcd690170b039.zip gcc-76aa78e9eb7ade737abc19cbea1bcd690170b039.tar.gz gcc-76aa78e9eb7ade737abc19cbea1bcd690170b039.tar.bz2 |
allocator.h (__shrink_to_fit): Simplify.
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
-rw-r--r-- | libstdc++-v3/ChangeLog | 13 | ||||
-rw-r--r-- | libstdc++-v3/include/bits/allocator.h | 30 | ||||
-rw-r--r-- | libstdc++-v3/include/bits/stl_bvector.h | 2 | ||||
-rw-r--r-- | libstdc++-v3/include/bits/stl_deque.h | 2 | ||||
-rw-r--r-- | libstdc++-v3/include/bits/stl_vector.h | 2 |
5 files changed, 24 insertions, 25 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index b259e9a..e456f59 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -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> diff --git a/libstdc++-v3/include/bits/allocator.h b/libstdc++-v3/include/bits/allocator.h index 6fccba5..4fc1410 100644 --- a/libstdc++-v3/include/bits/allocator.h +++ b/libstdc++-v3/include/bits/allocator.h @@ -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 diff --git a/libstdc++-v3/include/bits/stl_bvector.h b/libstdc++-v3/include/bits/stl_bvector.h index edf6629..30e7b2d 100644 --- a/libstdc++-v3/include/bits/stl_bvector.h +++ b/libstdc++-v3/include/bits/stl_bvector.h @@ -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 diff --git a/libstdc++-v3/include/bits/stl_deque.h b/libstdc++-v3/include/bits/stl_deque.h index 7ddfbc5..fab63f1 100644 --- a/libstdc++-v3/include/bits/stl_deque.h +++ b/libstdc++-v3/include/bits/stl_deque.h @@ -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 /** diff --git a/libstdc++-v3/include/bits/stl_vector.h b/libstdc++-v3/include/bits/stl_vector.h index 5fa5f52..4f61786 100644 --- a/libstdc++-v3/include/bits/stl_vector.h +++ b/libstdc++-v3/include/bits/stl_vector.h @@ -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 /** |