aboutsummaryrefslogtreecommitdiff
path: root/libbutl/fdstream.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2017-11-23 15:31:15 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2017-11-23 15:31:15 +0200
commit57287f26756a2a018e9a0b2412000da5a1bbebcd (patch)
treed3a648d5b746cecbb2fae4c98399ccf587e165ed /libbutl/fdstream.cxx
parentbb15620bcf2c6dec409719f8be27c62696b692d8 (diff)
Use uncaught_exceptions() if available
C++17 deprecated uncaught_exception() and GCC 8 now issues a warning.
Diffstat (limited to 'libbutl/fdstream.cxx')
-rw-r--r--libbutl/fdstream.cxx10
1 files changed, 9 insertions, 1 deletions
diff --git a/libbutl/fdstream.cxx b/libbutl/fdstream.cxx
index 9eb810a..18fcf11 100644
--- a/libbutl/fdstream.cxx
+++ b/libbutl/fdstream.cxx
@@ -42,12 +42,13 @@
#include <new> // bad_alloc
#include <limits> // numeric_limits
#include <cstring> // memcpy(), memmove()
-#include <exception> // uncaught_exception()
+#include <exception> // uncaught_exception[s]()
#include <stdexcept> // invalid_argument
#include <type_traits>
#include <system_error>
#endif
+#include <libbutl/ft/exception.hxx> // uncaught_exceptions
#include <libbutl/process-details.hxx>
#ifdef __cpp_modules
@@ -651,7 +652,14 @@ namespace butl
// using ofdstream in a dtor being called while unwinding the stack due to
// an exception.
//
+ // C++17 deprecated uncaught_exception() so use uncaught_exceptions() if
+ // available.
+ //
+#ifdef __cpp_lib_uncaught_exceptions
+ assert (!is_open () || !good () || uncaught_exceptions () != 0);
+#else
assert (!is_open () || !good () || uncaught_exception ());
+#endif
}
void ofdstream::