diff options
author | paolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-06-12 15:51:36 +0000 |
---|---|---|
committer | paolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-06-12 15:51:36 +0000 |
commit | 775d377d46fe81b10bc0d31eb3c0682212eda57c (patch) | |
tree | 35ec9f7a850f39851d2e1c34a6db9f76d61e6e77 /libstdc++-v3/include/bits/allocator.h | |
parent | f94fe54ef816cd619607e902fa4926bdfc6566c4 (diff) | |
download | gcc-775d377d46fe81b10bc0d31eb3c0682212eda57c.tar.gz |
2011-06-12 François Dumont <francois.cppdevs@free.fr>
Paolo Carlini <paolo.carlini@oracle.com>
* include/bits/allocator.h (__shrink_to_fit): Rename to
__shrink_to_fit_aux, fix.
* include/bits/stl_vector.h (_M_shrink_to_fit): Declare.
(shrink_to_fit): Use the latter.
* include/debug/vector (shrink_to_fit): Likewise.
* include/bits/vector.tcc (_M_shrink_to_fit): Define.
* include/bits/stl_deque.h (_M_shrink_to_fit): Declare.
(shrink_to_fit): Use the latter.
* include/debug/deque (shrink_to_fit): Likewise.
* include/bits/deque.tcc (_M_shrink_to_fit): Define.
* include/bits/vector.tcc (vector<bool>::_M_reallocate): Add.
* include/bits/stl_bvector.h (_M_shrink_to_fit): Declare.
(shrink_to_fit): Use the latter.
(reserve): Use _M_reallocate, move inline.
(_Bvector_base<>::_S_nword): Add, use it throughout.
* include/debug/string (shrink_to_fit): Redo.
* include/ext/vstring.h (shrink_to_fit): Optimize.
* include/bits/basic_string.h (shrink_to_fit): Likewise.
* testsuite/21_strings/debug/shrink_to_fit.cc: New.
* testsuite/23_containers/vector/debug/shrink_to_fit.cc: Likewise.
* testsuite/23_containers/vector/debug/bool/shrink_to_fit.cc:
Likewise.
* testsuite/23_containers/vector/bool/capacity/shrink_to_fit.cc:
Likewise.
* testsuite/23_containers/deque/debug/shrink_to_fit.cc: Likewise.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@174967 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3/include/bits/allocator.h')
-rw-r--r-- | libstdc++-v3/include/bits/allocator.h | 30 |
1 files changed, 20 insertions, 10 deletions
diff --git a/libstdc++-v3/include/bits/allocator.h b/libstdc++-v3/include/bits/allocator.h index 7067fa09bd4..680195082da 100644 --- a/libstdc++-v3/include/bits/allocator.h +++ b/libstdc++-v3/include/bits/allocator.h @@ -184,18 +184,28 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION }; #ifdef __GXX_EXPERIMENTAL_CXX0X__ + template<typename _Tp, bool + = __or_<is_copy_constructible<typename _Tp::value_type>, + is_nothrow_move_constructible<typename _Tp::value_type>>::value> + struct __shrink_to_fit_aux + { static bool _S_do_it(_Tp&) { return false; } }; + template<typename _Tp> - bool - __shrink_to_fit(_Tp& __v) + struct __shrink_to_fit_aux<_Tp, true> { - __try - { - _Tp(__v).swap(__v); - return true; - } - __catch(...) - { return false; } - } + static bool + _S_do_it(_Tp& __c) + { + __try + { + _Tp(__make_move_if_noexcept_iterator(__c.begin()), + __make_move_if_noexcept_iterator(__c.end())).swap(__c); + return true; + } + __catch(...) + { return false; } + } + }; template<typename _Alloc, typename _Tp> class __alloctr_rebind_helper |