File tree Expand file tree Collapse file tree 3 files changed +14
-11
lines changed
docs/mkdocs/docs/examples Expand file tree Collapse file tree 3 files changed +14
-11
lines changed Original file line number Diff line number Diff line change 1
1
#include < iostream>
2
2
#include < nlohmann/json.hpp>
3
3
4
- #if !defined(JSON_NOEXCEPTION) && !defined(JSON_THROW_USER) && !defined(JSON_THROW)
5
- #define JSON_THROW (exception ) throw exception
6
- #else
7
- #include < cstdlib>
8
- #define JSON_THROW (exception ) std::abort()
9
- #endif
10
-
11
4
using json = nlohmann::json;
12
5
13
6
namespace ns
Original file line number Diff line number Diff line change 168
168
#define JSON_INTERNAL_CATCH (exception ) catch (exception)
169
169
#else
170
170
#include < cstdlib>
171
- std::forward<T>(exception);
172
171
#define JSON_THROW (exception ) std::abort()
173
172
#define JSON_TRY if (true )
174
173
#define JSON_CATCH (exception ) if (false )
@@ -249,7 +248,13 @@ namespace detail
249
248
template <typename T>
250
249
[[noreturn]] inline void json_throw_from_serialize_macro (T&& exception)
251
250
{
252
- JSON_THROW (std::forward<T>(exception));
251
+ #if defined(__cpp_exceptions) || defined(__EXCEPTIONS) || defined(_CPPUNWIND) || defined(EXCEPTIONS)
252
+ throw std::forward<T>(exception);
253
+ #else
254
+ // Forward the exception (even if unused) and abort
255
+ std::forward<T>(exception);
256
+ std::abort ();
257
+ #endif
253
258
}
254
259
} // namespace detail
255
260
NLOHMANN_JSON_NAMESPACE_END
Original file line number Diff line number Diff line change @@ -2534,7 +2534,6 @@ JSON_HEDLEY_DIAGNOSTIC_POP
2534
2534
#define JSON_INTERNAL_CATCH(exception) catch(exception)
2535
2535
#else
2536
2536
#include <cstdlib>
2537
- std::forward<T>(exception);
2538
2537
#define JSON_THROW(exception) std::abort()
2539
2538
#define JSON_TRY if(true)
2540
2539
#define JSON_CATCH(exception) if(false)
@@ -2615,7 +2614,13 @@ namespace detail
2615
2614
template<typename T>
2616
2615
[[noreturn]] inline void json_throw_from_serialize_macro(T&& exception)
2617
2616
{
2618
- JSON_THROW(std::forward<T>(exception));
2617
+ #if defined(__cpp_exceptions) || defined(__EXCEPTIONS) || defined(_CPPUNWIND) || defined(EXCEPTIONS)
2618
+ throw std::forward<T>(exception);
2619
+ #else
2620
+ // Forward the exception (even if unused) and abort
2621
+ std::forward<T>(exception);
2622
+ std::abort();
2623
+ #endif
2619
2624
}
2620
2625
} // namespace detail
2621
2626
NLOHMANN_JSON_NAMESPACE_END
You can’t perform that action at this time.
0 commit comments