From 5ba1c1ad8514362dba596f228eb20eb13f63d948 Mon Sep 17 00:00:00 2001 From: Evgen Bodunov Date: Wed, 19 Sep 2018 11:30:44 +0300 Subject: [PATCH] HAS_UNCAUGHT_EXCEPTIONS definition. Added some flexibility for usage of std::uncaught_exceptions(). Xcode 10 uses clang and perfectly compiles C++17, but std::uncaught_exceptions() is available only on iOS 10+ devices. When application supports iOS 9 devices and uses C++17 there is no way to build it, except drop iOS 9 support or remove C++17 code. Using this define we could configure should date.h use std::uncaught_exceptions() or not. --- include/date/date.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/include/date/date.h b/include/date/date.h index 5938c4e..51cea14 100644 --- a/include/date/date.h +++ b/include/date/date.h @@ -126,6 +126,14 @@ namespace date # define NOEXCEPT noexcept #endif +#ifndef HAS_UNCAUGHT_EXCEPTIONS +# if __cplusplus > 201703 +# define HAS_UNCAUGHT_EXCEPTIONS 1 +# else +# define HAS_UNCAUGHT_EXCEPTIONS 0 +# endif +#endif // HAS_UNCAUGHT_EXCEPTIONS + #ifndef HAS_VOID_T # if __cplusplus >= 201703 # define HAS_VOID_T 1 @@ -1030,7 +1038,7 @@ public: ~save_ostream() { if ((this->flags_ & std::ios::unitbuf) && -#if __cplusplus >= 201703 +#if HAS_UNCAUGHT_EXCEPTIONS std::uncaught_exceptions() == 0 && #else !std::uncaught_exception() &&