glibcxx_eh_cxx17.cpp 488 B

1234567891011121314151617
  1. #include <cxxabi.h>
  2. /**
  3. * libc++ expects std::uncaught_exceptions() to be provided by C++ runtime library.
  4. *
  5. * GCC versions prior to GCC 6 did not provide this function yet, but it can be
  6. * implemented using its API.
  7. *
  8. * This implementation should cover ubuntu-12, ubuntu-14, ubuntu-16.
  9. */
  10. namespace std {
  11. int uncaught_exceptions() noexcept {
  12. const auto* globals{__cxxabiv1::__cxa_get_globals()};
  13. return static_cast<int>(globals->uncaughtExceptions);
  14. }
  15. }