@@ -2657,6 +2657,57 @@ using is_detected_convertible =
2657
2657
inline void to_json(nlohmann::json& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \
2658
2658
inline void from_json(const nlohmann::json& nlohmann_json_j, Type& nlohmann_json_t) { Type nlohmann_json_default_obj; NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM_WITH_DEFAULT, __VA_ARGS__)) }
2659
2659
2660
+ #define NLOHMANN_DEFINE_TYPE_T_TO_IMPL(ReturnType, Type, ...) \
2661
+ template<typename BasicJsonType> \
2662
+ ReturnType to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) \
2663
+ { \
2664
+ NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) \
2665
+ }
2666
+
2667
+ #define NLOHMANN_DEFINE_TYPE_T_IMPL(ReturnType, Type, ...) \
2668
+ NLOHMANN_DEFINE_TYPE_T_TO_IMPL(ReturnType, Type, __VA_ARGS__) \
2669
+ template<typename BasicJsonType> \
2670
+ ReturnType from_json(const BasicJsonType& nlohmann_json_j, Type& nlohmann_json_t) \
2671
+ { \
2672
+ NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM, __VA_ARGS__)) \
2673
+ }
2674
+
2675
+ #define NLOHMANN_DEFINE_TYPE_T_WITH_DEFAULT_IMPL(ReturnType, Type, ...) \
2676
+ NLOHMANN_DEFINE_TYPE_T_TO_IMPL(ReturnType, Type, __VA_ARGS__) \
2677
+ template<typename BasicJsonType> \
2678
+ ReturnType from_json(const BasicJsonType& nlohmann_json_j, Type& nlohmann_json_t) \
2679
+ { \
2680
+ Type nlohmann_json_default_obj; \
2681
+ NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM_WITH_DEFAULT, __VA_ARGS__)) \
2682
+ }
2683
+
2684
+ /*!
2685
+ @brief macro to briefly define intrusive serialization of a given type to/from any basic_json object
2686
+ @def NLOHMANN_DEFINE_TYPE_INTRUSIVE_T
2687
+ @since version 3.10.6
2688
+ */
2689
+ #define NLOHMANN_DEFINE_TYPE_INTRUSIVE_T(Type, ...) NLOHMANN_DEFINE_TYPE_T_IMPL(friend void, Type, __VA_ARGS__)
2690
+
2691
+ /*!
2692
+ @brief macro to briefly define non-intrusive serialization of a given type to/from any basic_json object
2693
+ @def NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_T
2694
+ @since version 3.10.6
2695
+ */
2696
+ #define NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_T(Type, ...) NLOHMANN_DEFINE_TYPE_T_IMPL(void, Type, __VA_ARGS__)
2697
+
2698
+ /*!
2699
+ @brief macro to briefly define intrusive serialization of a given type to/from any basic_json object (works with missing fields in json)
2700
+ @def NLOHMANN_DEFINE_TYPE_INTRUSIVE_T_WITH_DEFAULT
2701
+ @since version 3.10.6
2702
+ */
2703
+ #define NLOHMANN_DEFINE_TYPE_INTRUSIVE_T_WITH_DEFAULT(Type, ...) NLOHMANN_DEFINE_TYPE_T_WITH_DEFAULT_IMPL(friend void, Type, __VA_ARGS__)
2704
+
2705
+ /*!
2706
+ @brief macro to briefly define non-intrusive serialization of a given type to/from any basic_json object (works with missing fields in json)
2707
+ @def NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_T_WITH_DEFAULT
2708
+ @since version 3.10.6
2709
+ */
2710
+ #define NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_T_WITH_DEFAULT(Type, ...) NLOHMANN_DEFINE_TYPE_T_WITH_DEFAULT_IMPL(void, Type, __VA_ARGS__)
2660
2711
2661
2712
// inspired from https://stackoverflow.com/a/26745591
2662
2713
// allows to call any std function as if (e.g. with begin):
@@ -2696,40 +2747,6 @@ using is_detected_convertible =
2696
2747
{ \
2697
2748
}
2698
2749
2699
- /*!
2700
- @brief macro to briefly define intrusive serialization of a given type to/from any basic_json object
2701
- @def NLOHMANN_DEFINE_TYPE_INTRUSIVE_T
2702
- @since version 3.9.2
2703
- */
2704
- #define NLOHMANN_DEFINE_TYPE_INTRUSIVE_T(Type, ...) \
2705
- template<typename BasicJsonType> \
2706
- friend void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) \
2707
- { \
2708
- NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) \
2709
- } \
2710
- template<typename BasicJsonType> \
2711
- friend void from_json(const BasicJsonType& nlohmann_json_j, Type& nlohmann_json_t) \
2712
- { \
2713
- NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM, __VA_ARGS__)) \
2714
- }
2715
-
2716
- /*!
2717
- @brief macro to briefly define non-intrusive serialization of a given type to/from any basic_json object
2718
- @def NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_T
2719
- @since version 3.9.2
2720
- */
2721
- #define NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_T(Type, ...) \
2722
- template<typename BasicJsonType> \
2723
- void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) \
2724
- { \
2725
- NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) \
2726
- } \
2727
- template<typename BasicJsonType> \
2728
- void from_json(const BasicJsonType& nlohmann_json_j, Type& nlohmann_json_t) \
2729
- { \
2730
- NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM, __VA_ARGS__)) \
2731
- }
2732
-
2733
2750
#ifndef JSON_USE_IMPLICIT_CONVERSIONS
2734
2751
#define JSON_USE_IMPLICIT_CONVERSIONS 1
2735
2752
#endif
@@ -18627,7 +18644,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
18627
18644
detail::parser_callback_t<basic_json>cb = nullptr,
18628
18645
const bool allow_exceptions = true,
18629
18646
const bool ignore_comments = false
18630
- )
18647
+ )
18631
18648
{
18632
18649
return ::nlohmann::detail::parser<basic_json, InputAdapterType>(std::move(adapter),
18633
18650
std::move(cb), allow_exceptions, ignore_comments);
0 commit comments