-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcpp.hint
4 lines (4 loc) · 1.12 KB
/
cpp.hint
1
2
3
4
// Hint files help the Visual Studio IDE interpret Visual C++ identifiers
// such as names of functions and macros.
// For more information see https://go.microsoft.com/fwlink/?linkid=865984
#define NLOHMANN_JSON_SERIALIZE_ENUM(ENUM_TYPE, __VA_ARGS__) template<typename BasicJsonType> inline void to_json(BasicJsonType& j, const ENUM_TYPE& e) { static_assert(std::is_enum<ENUM_TYPE>::value, #ENUM_TYPE " must be an enum!"); static const std::pair<ENUM_TYPE, BasicJsonType> m[] = __VA_ARGS__; auto it = std::find_if(std::begin(m), std::end(m), [e](const std::pair<ENUM_TYPE, BasicJsonType>& ej_pair) -> bool { return ej_pair.first == e; }); j = ((it != std::end(m)) ? it : std::begin(m))->second; } template<typename BasicJsonType> inline void from_json(const BasicJsonType& j, ENUM_TYPE& e) { static_assert(std::is_enum<ENUM_TYPE>::value, #ENUM_TYPE " must be an enum!"); static const std::pair<ENUM_TYPE, BasicJsonType> m[] = __VA_ARGS__; auto it = std::find_if(std::begin(m), std::end(m), [&j](const std::pair<ENUM_TYPE, BasicJsonType>& ej_pair) -> bool { return ej_pair.second == j; }); e = ((it != std::end(m)) ? it : std::begin(m))->first; }