Commit 99f04955 by Jonathan Wakely Committed by Jonathan Wakely

Only do shrink_to_fit() when exceptions enabled

	* include/bits/allocator.h (__shrink_to_fit_aux<T, true>::_S_do_it):
	Do nothing if exceptions are disabled.
	* include/bits/basic_string.h (basic_string::shrink_to_fit): Likewise.

From-SVN: r227870
parent 385399a8
2015-09-17 Jonathan Wakely <jwakely@redhat.com>
* include/bits/allocator.h (__shrink_to_fit_aux<T, true>::_S_do_it):
Do nothing if exceptions are disabled.
* include/bits/basic_string.h (basic_string::shrink_to_fit): Likewise.
2015-09-16 Jonathan Wakely <jwakely@redhat.com> 2015-09-16 Jonathan Wakely <jwakely@redhat.com>
PR libstdc++/67173 PR libstdc++/67173
......
...@@ -209,15 +209,19 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -209,15 +209,19 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
static bool static bool
_S_do_it(_Tp& __c) noexcept _S_do_it(_Tp& __c) noexcept
{ {
__try #if __cpp_exceptions
try
{ {
_Tp(__make_move_if_noexcept_iterator(__c.begin()), _Tp(__make_move_if_noexcept_iterator(__c.begin()),
__make_move_if_noexcept_iterator(__c.end()), __make_move_if_noexcept_iterator(__c.end()),
__c.get_allocator()).swap(__c); __c.get_allocator()).swap(__c);
return true; return true;
} }
__catch(...) catch(...)
{ return false; } { return false; }
#else
return false;
#endif
} }
}; };
#endif #endif
......
...@@ -833,13 +833,15 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 ...@@ -833,13 +833,15 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
void void
shrink_to_fit() noexcept shrink_to_fit() noexcept
{ {
#if __cpp_exceptions
if (capacity() > size()) if (capacity() > size())
{ {
__try try
{ reserve(0); } { reserve(0); }
__catch(...) catch(...)
{ } { }
} }
#endif
} }
#endif #endif
...@@ -3282,12 +3284,14 @@ _GLIBCXX_END_NAMESPACE_CXX11 ...@@ -3282,12 +3284,14 @@ _GLIBCXX_END_NAMESPACE_CXX11
void void
shrink_to_fit() _GLIBCXX_NOEXCEPT shrink_to_fit() _GLIBCXX_NOEXCEPT
{ {
#if __cpp_exceptions
if (capacity() > size()) if (capacity() > size())
{ {
__try try
{ reserve(0); } { reserve(0); }
__catch(...) catch(...)
{ } { }
#endif
} }
} }
#endif #endif
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment