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 11#include < iostream>
22#include < nlohmann/json.hpp>
33
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-
114using json = nlohmann::json;
125
136namespace ns
Original file line number Diff line number Diff line change 168168 #define JSON_INTERNAL_CATCH (exception ) catch (exception)
169169#else
170170 #include < cstdlib>
171- std::forward<T>(exception);
172171 #define JSON_THROW (exception ) std::abort()
173172 #define JSON_TRY if (true )
174173 #define JSON_CATCH (exception ) if (false )
@@ -249,7 +248,13 @@ namespace detail
249248template <typename T>
250249[[noreturn]] inline void json_throw_from_serialize_macro (T&& exception)
251250{
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
253258}
254259} // namespace detail
255260NLOHMANN_JSON_NAMESPACE_END
Original file line number Diff line number Diff line change @@ -2534,7 +2534,6 @@ JSON_HEDLEY_DIAGNOSTIC_POP
25342534 #define JSON_INTERNAL_CATCH(exception) catch(exception)
25352535#else
25362536 #include <cstdlib>
2537- std::forward<T>(exception);
25382537 #define JSON_THROW(exception) std::abort()
25392538 #define JSON_TRY if(true)
25402539 #define JSON_CATCH(exception) if(false)
@@ -2615,7 +2614,13 @@ namespace detail
26152614template<typename T>
26162615[[noreturn]] inline void json_throw_from_serialize_macro(T&& exception)
26172616{
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
26192624}
26202625} // namespace detail
26212626NLOHMANN_JSON_NAMESPACE_END
You can’t perform that action at this time.
0 commit comments