From b8e8b6ffbf8ccc2471ff426807c7fe455e9ede17 Mon Sep 17 00:00:00 2001 From: Mathieu Champlon Date: Sun, 25 Mar 2018 17:02:58 +0200 Subject: [PATCH] Fixed uncaught_exceptions usage with clang MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit For some reason clang seems so believe uncaught_exceptions does not belong to the std namespace: no member named 'uncaught_exceptions' in namespace 'std'; did you mean simply 'uncaught_exceptions'? I haven't found any indication confirming this, but let's just support both… --- include/turtle/config.hpp | 2 +- include/turtle/detail/function.hpp | 5 +++-- include/turtle/detail/function_impl_template.hpp | 4 ++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/include/turtle/config.hpp b/include/turtle/config.hpp index 96a11c8..16b0ed5 100644 --- a/include/turtle/config.hpp +++ b/include/turtle/config.hpp @@ -94,7 +94,7 @@ # endif #endif -#if defined(__cplusplus) && (__cplusplus >= 201703L) || \ +#if defined(__cpp_lib_uncaught_exceptions) || \ defined(_MSC_VER) && (_MSC_VER >= 1900) # ifndef MOCK_NO_UNCAUGHT_EXCEPTIONS # define MOCK_UNCAUGHT_EXCEPTIONS diff --git a/include/turtle/detail/function.hpp b/include/turtle/detail/function.hpp index a631310..7432384 100644 --- a/include/turtle/detail/function.hpp +++ b/include/turtle/detail/function.hpp @@ -87,10 +87,11 @@ namespace detail E* e_; }; - inline int uncaught_exceptions() + inline int exceptions() { #ifdef MOCK_UNCAUGHT_EXCEPTIONS - return std::uncaught_exceptions(); + using namespace std; + return uncaught_exceptions(); #else return std::uncaught_exception() ? 1 : 0; #endif diff --git a/include/turtle/detail/function_impl_template.hpp b/include/turtle/detail/function_impl_template.hpp index 2a8d74a..4e322db 100644 --- a/include/turtle/detail/function_impl_template.hpp +++ b/include/turtle/detail/function_impl_template.hpp @@ -43,12 +43,12 @@ namespace detail function_impl() : context_( 0 ) , valid_( true ) + , exceptions_( exceptions() ) , mutex_( boost::make_shared< mutex >() ) - , exceptions_( uncaught_exceptions() ) {} virtual ~function_impl() { - if( valid_ && exceptions_ >= uncaught_exceptions() ) + if( valid_ && exceptions_ >= exceptions() ) for( expectations_cit it = expectations_.begin(); it != expectations_.end(); ++it ) if( ! it->verify() )