diff options
author | paolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-06-08 11:07:24 +0000 |
---|---|---|
committer | paolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-06-08 11:07:24 +0000 |
commit | b9f2ba1ee70c5d01eba0bdfcac78cbae4c33abaa (patch) | |
tree | 13e6b3a72d25efb2390fe71ac59d916d84cffcca /libstdc++-v3/include/bits/allocator.h | |
parent | 934574417663b03dd7329cb3a8d00079ccf73985 (diff) | |
download | ppe42-gcc-b9f2ba1ee70c5d01eba0bdfcac78cbae4c33abaa.tar.gz ppe42-gcc-b9f2ba1ee70c5d01eba0bdfcac78cbae4c33abaa.zip |
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.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@174802 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, 10 insertions, 20 deletions
diff --git a/libstdc++-v3/include/bits/allocator.h b/libstdc++-v3/include/bits/allocator.h index 6fccba51bb1..4fc14105cd3 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 |