Skip to content

Commit

Permalink
Allow overriding THROW/CATCH/TRY macros with _USER versions #938
Browse files Browse the repository at this point in the history
  • Loading branch information
Kaido committed Jan 28, 2018
1 parent b3bd3b7 commit 236f5a7
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
14 changes: 14 additions & 0 deletions develop/detail/macro_scope.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,20 @@
#define JSON_CATCH(exception) if(false)
#endif

// override exception macros
#if define(JSON_THROW_USER)
#undef JSON_THROW
#define JSON_THROW JSON_THROW_USER
#endif
#if define(JSON_TRY_USER)
#undef JSON_TRY
#define JSON_TRY JSON_TRY_USER
#endif
#if define(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)
Expand Down
14 changes: 14 additions & 0 deletions src/json.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,20 @@ using json = basic_json<>;
#define JSON_CATCH(exception) if(false)
#endif

// override exception macros
#if define(JSON_THROW_USER)
#undef JSON_THROW
#define JSON_THROW JSON_THROW_USER
#endif
#if define(JSON_TRY_USER)
#undef JSON_TRY
#define JSON_TRY JSON_TRY_USER
#endif
#if define(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)
Expand Down

0 comments on commit 236f5a7

Please sign in to comment.