summaryrefslogtreecommitdiffstats
path: root/libstdc++-v3/include/debug
diff options
context:
space:
mode:
authorpaolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>2011-06-12 15:51:36 +0000
committerpaolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>2011-06-12 15:51:36 +0000
commit775d377d46fe81b10bc0d31eb3c0682212eda57c (patch)
tree35ec9f7a850f39851d2e1c34a6db9f76d61e6e77 /libstdc++-v3/include/debug
parentf94fe54ef816cd619607e902fa4926bdfc6566c4 (diff)
downloadppe42-gcc-775d377d46fe81b10bc0d31eb3c0682212eda57c.tar.gz
ppe42-gcc-775d377d46fe81b10bc0d31eb3c0682212eda57c.zip
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/debug')
-rw-r--r--libstdc++-v3/include/debug/deque7
-rw-r--r--libstdc++-v3/include/debug/string15
-rw-r--r--libstdc++-v3/include/debug/vector10
3 files changed, 29 insertions, 3 deletions
diff --git a/libstdc++-v3/include/debug/deque b/libstdc++-v3/include/debug/deque
index 749fc2e6cab..5b6bdeb544a 100644
--- a/libstdc++-v3/include/debug/deque
+++ b/libstdc++-v3/include/debug/deque
@@ -277,7 +277,12 @@ namespace __debug
#endif
#ifdef __GXX_EXPERIMENTAL_CXX0X__
- using _Base::shrink_to_fit;
+ void
+ shrink_to_fit()
+ {
+ if (_Base::_M_shrink_to_fit())
+ this->_M_invalidate_all();
+ }
#endif
using _Base::empty;
diff --git a/libstdc++-v3/include/debug/string b/libstdc++-v3/include/debug/string
index b6d2b4b34ea..9e0ad61bdef 100644
--- a/libstdc++-v3/include/debug/string
+++ b/libstdc++-v3/include/debug/string
@@ -237,7 +237,20 @@ namespace __gnu_debug
{ this->resize(__n, _CharT()); }
#ifdef __GXX_EXPERIMENTAL_CXX0X__
- using _Base::shrink_to_fit;
+ void
+ shrink_to_fit()
+ {
+ if (capacity() > size())
+ {
+ __try
+ {
+ reserve(0);
+ this->_M_invalidate_all();
+ }
+ __catch(...)
+ { }
+ }
+ }
#endif
using _Base::capacity;
diff --git a/libstdc++-v3/include/debug/vector b/libstdc++-v3/include/debug/vector
index 6072515dac3..1b80974d38c 100644
--- a/libstdc++-v3/include/debug/vector
+++ b/libstdc++-v3/include/debug/vector
@@ -280,7 +280,15 @@ namespace __debug
#endif
#ifdef __GXX_EXPERIMENTAL_CXX0X__
- using _Base::shrink_to_fit;
+ void
+ shrink_to_fit()
+ {
+ if (_Base::_M_shrink_to_fit())
+ {
+ _M_guaranteed_capacity = _Base::capacity();
+ this->_M_invalidate_all();
+ }
+ }
#endif
size_type
OpenPOWER on IntegriCloud