Only do shrink_to_fit() when exceptions enabled
authorJonathan Wakely <jwakely@redhat.com>
Thu, 17 Sep 2015 14:56:46 +0000 (15:56 +0100)
committerJonathan Wakely <redi@gcc.gnu.org>
Thu, 17 Sep 2015 14:56:46 +0000 (15:56 +0100)
* 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

libstdc++-v3/ChangeLog
libstdc++-v3/include/bits/allocator.h
libstdc++-v3/include/bits/basic_string.h

index b8c11843632c54d5ce4df6f6de4bc0bffcc5283f..2bcfa161fcfa4b69a1f194f0171e69ccd2ecc5b9 100644 (file)
@@ -1,3 +1,9 @@
+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>
 
        PR libstdc++/67173
index 6fd3214cd02df5931a76202fdcdfc552bcbc863a..0131521c5cd9e91b3ad5fc323b37f621753446d6 100644 (file)
@@ -209,15 +209,19 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       static bool
       _S_do_it(_Tp& __c) noexcept
       {
-       __try
+#if __cpp_exceptions
+       try
          {
            _Tp(__make_move_if_noexcept_iterator(__c.begin()),
                __make_move_if_noexcept_iterator(__c.end()),
                __c.get_allocator()).swap(__c);
            return true;
          }
-       __catch(...)
+       catch(...)
          { return false; }
+#else
+       return false;
+#endif
       }
     };
 #endif
index e6e7bb525ba7bfa2aa77b5d5ce578ce56707940e..b5e7e3628c625ffcb0eb2c70ea3775dc0ca6c0c5 100644 (file)
@@ -833,13 +833,15 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
       void
       shrink_to_fit() noexcept
       {
+#if __cpp_exceptions
        if (capacity() > size())
          {
-           __try
+           try
              { reserve(0); }
-           __catch(...)
+           catch(...)
              { }
          }
+#endif
       }
 #endif
 
@@ -3282,12 +3284,14 @@ _GLIBCXX_END_NAMESPACE_CXX11
       void
       shrink_to_fit() _GLIBCXX_NOEXCEPT
       {
+#if __cpp_exceptions
        if (capacity() > size())
          {
-           __try
+           try
              { reserve(0); }
-           __catch(...)
+           catch(...)
              { }
+#endif
          }
       }
 #endif