From 1bd815993d7f5b13048ebd4073b5278f9ab82cfd Mon Sep 17 00:00:00 2001 From: Paul-Edouard Sarlin Date: Mon, 5 Feb 2024 22:24:55 +0100 Subject: [PATCH] Pull changes from COLMAP --- _pyceres/logging.h | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/_pyceres/logging.h b/_pyceres/logging.h index b28b547..193c9cb 100644 --- a/_pyceres/logging.h +++ b/_pyceres/logging.h @@ -109,9 +109,17 @@ class LogMessageFatalThrow : public google::LogMessage { // so we do it here. delete result.str_; }; - [[noreturn]] ~LogMessageFatalThrow() noexcept(false) { + ~LogMessageFatalThrow() noexcept(false) { Flush(); - throw T(prefix_ + message_); +#if defined(__cpp_lib_uncaught_exceptions) && \ + (__cpp_lib_uncaught_exceptions >= 201411L) + if (std::uncaught_exceptions() == 0) +#else + if (!std::uncaught_exception()) +#endif + { + throw T(prefix_ + message_); + } }; private: @@ -124,7 +132,7 @@ using LogMessageFatalThrowDefault = LogMessageFatalThrow; template T ThrowCheckNotNull(const char* file, int line, const char* names, T&& t) { if (t == nullptr) { - LogMessageFatalThrowDefault(file, line, new std::string(names)); + LogMessageFatalThrowDefault(file, line).stream() << names; } return std::forward(t); }