From d0c9e5fffc1bd1abf417143fb61021c362d10829 Mon Sep 17 00:00:00 2001 From: Kaido Date: Sun, 28 Jan 2018 14:42:13 -0800 Subject: [PATCH] Allow overriding THROW/CATCH/TRY macros with no-exceptions (redo) #938 --- develop/detail/macro_scope.hpp | 14 ++++++++++++++ src/json.hpp | 14 ++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/develop/detail/macro_scope.hpp b/develop/detail/macro_scope.hpp index 8316c077..e6752218 100644 --- a/develop/detail/macro_scope.hpp +++ b/develop/detail/macro_scope.hpp @@ -46,6 +46,20 @@ #define JSON_CATCH(exception) if(false) #endif +// override exception macros +#if defined(JSON_THROW_USER) + #undef JSON_THROW + #define JSON_THROW JSON_THROW_USER +#endif +#if defined(JSON_TRY_USER) + #undef JSON_TRY + #define JSON_TRY JSON_TRY_USER +#endif +#if defined(JSON_CATCH_USER) + #undef JSON_CATCH + #define JSON_CATCH JSON_CATCH_USER +#endif + // manual branch prediction #if defined(__clang__) || defined(__GNUC__) || defined(__GNUG__) #define JSON_LIKELY(x) __builtin_expect(!!(x), 1) diff --git a/src/json.hpp b/src/json.hpp index e12904a8..f170ca81 100644 --- a/src/json.hpp +++ b/src/json.hpp @@ -156,6 +156,20 @@ using json = basic_json<>; #define JSON_CATCH(exception) if(false) #endif +// override exception macros +#if defined(JSON_THROW_USER) + #undef JSON_THROW + #define JSON_THROW JSON_THROW_USER +#endif +#if defined(JSON_TRY_USER) + #undef JSON_TRY + #define JSON_TRY JSON_TRY_USER +#endif +#if defined(JSON_CATCH_USER) + #undef JSON_CATCH + #define JSON_CATCH JSON_CATCH_USER +#endif + // manual branch prediction #if defined(__clang__) || defined(__GNUC__) || defined(__GNUG__) #define JSON_LIKELY(x) __builtin_expect(!!(x), 1)