File tree Expand file tree Collapse file tree 3 files changed +20
-20
lines changed Expand file tree Collapse file tree 3 files changed +20
-20
lines changed Original file line number Diff line number Diff line change 2929#include < nlohmann/detail/string_concat.hpp>
3030#include < nlohmann/detail/value_t.hpp>
3131
32+ /* helper for strict enum error reporting */
33+ template <typename BasicJsonType>
34+ inline void throw_enum_error (const BasicJsonType& j, const char * enum_type)
35+ {
36+ JSON_THROW (::nlohmann::detail::type_error::create (
37+ 302 ,
38+ std::string (" invalid value for " ) + enum_type + " : " + j.dump (),
39+ &j));
40+ }
41+
3242// include after macro_scope.hpp
3343#ifdef JSON_HAS_CPP_17
3444 #include < optional> // optional
Original file line number Diff line number Diff line change 260260@since version 3.12.0
261261*/
262262
263- /* helper for strict enum error reporting */
264- template <typename BasicJsonType>
265- inline void throw_enum_error (const BasicJsonType& j, const char * enum_type)
266- {
267- JSON_THROW (::nlohmann::detail::type_error::create (
268- 302 ,
269- std::string (" invalid value for " ) + enum_type + " : " + j.dump (),
270- &j));
271- }
272-
273263#define NLOHMANN_JSON_SERIALIZE_ENUM_STRICT (ENUM_TYPE, ...) \
274264 template <typename BasicJsonType> \
275265 inline void to_json (BasicJsonType& j, const ENUM_TYPE& e) \
Original file line number Diff line number Diff line change @@ -2624,16 +2624,6 @@ JSON_HEDLEY_DIAGNOSTIC_POP
26242624@since version 3.12.0
26252625*/
26262626
2627- /* helper for strict enum error reporting */
2628- template<typename BasicJsonType>
2629- inline void throw_enum_error(const BasicJsonType& j, const char* enum_type)
2630- {
2631- JSON_THROW(::nlohmann::detail::type_error::create(
2632- 302,
2633- std::string("invalid value for ") + enum_type + ": " + j.dump(),
2634- &j));
2635- }
2636-
26372627#define NLOHMANN_JSON_SERIALIZE_ENUM_STRICT(ENUM_TYPE, ...) \
26382628 template<typename BasicJsonType> \
26392629 inline void to_json(BasicJsonType& j, const ENUM_TYPE& e) \
@@ -4914,6 +4904,16 @@ NLOHMANN_JSON_NAMESPACE_END
49144904// #include <nlohmann/detail/value_t.hpp>
49154905
49164906
4907+ /* helper for strict enum error reporting */
4908+ template<typename BasicJsonType>
4909+ inline void throw_enum_error(const BasicJsonType& j, const char* enum_type)
4910+ {
4911+ JSON_THROW(::nlohmann::detail::type_error::create(
4912+ 302,
4913+ std::string("invalid value for ") + enum_type + ": " + j.dump(),
4914+ &j));
4915+ }
4916+
49174917// include after macro_scope.hpp
49184918#ifdef JSON_HAS_CPP_17
49194919 #include <optional> // optional
You can’t perform that action at this time.
0 commit comments