fix compile

This commit is contained in:
ouwou
2020-11-01 15:17:19 -05:00
parent 534bfccf23
commit 2d5439ba90

View File

@@ -12,7 +12,7 @@ struct is_optional<::std::optional<T>> : ::std::true_type {};
template<typename T> template<typename T>
inline void json_direct(const ::nlohmann::json &j, const char *key, T &val) { inline void json_direct(const ::nlohmann::json &j, const char *key, T &val) {
if constexpr (is_optional<T>::value) if constexpr (is_optional<T>::value)
val = j.at(key).get<T::value_type>(); val = j.at(key).get<typename T::value_type>();
else else
j.at(key).get_to(val); j.at(key).get_to(val);
} }
@@ -21,7 +21,7 @@ template<typename T>
inline void json_optional(const ::nlohmann::json &j, const char *key, T &val) { inline void json_optional(const ::nlohmann::json &j, const char *key, T &val) {
if constexpr (is_optional<T>::value) { if constexpr (is_optional<T>::value) {
if (j.contains(key)) if (j.contains(key))
val = j.at(key).get<T::value_type>(); val = j.at(key).get<typename T::value_type>();
else else
val = ::std::nullopt; val = ::std::nullopt;
} else { } else {
@@ -35,7 +35,7 @@ inline void json_nullable(const ::nlohmann::json &j, const char *key, T &val) {
if constexpr (is_optional<T>::value) { if constexpr (is_optional<T>::value) {
const auto &at = j.at(key); const auto &at = j.at(key);
if (!at.is_null()) if (!at.is_null())
val = at.get<T::value_type>(); val = at.get<typename T::value_type>();
else else
val = ::std::nullopt; val = ::std::nullopt;
} else { } else {
@@ -51,7 +51,7 @@ inline void json_optional_nullable(const ::nlohmann::json &j, const char *key, T
if (j.contains(key)) { if (j.contains(key)) {
const auto &at = j.at(key); const auto &at = j.at(key);
if (!at.is_null()) if (!at.is_null())
val = at.get<T::value_type>(); val = at.get<typename T::value_type>();
else else
val = ::std::nullopt; val = ::std::nullopt;
} else { } else {
@@ -72,7 +72,7 @@ inline void json_update_optional_nullable(const ::nlohmann::json &j, const char
if (j.contains(key)) { if (j.contains(key)) {
const auto &at = j.at(key); const auto &at = j.at(key);
if (!at.is_null()) if (!at.is_null())
val = at.get<T::value_type>(); val = at.get<typename T::value_type>();
else else
val = ::std::nullopt; val = ::std::nullopt;
} }
@@ -95,7 +95,7 @@ inline void json_update_optional_nullable_default(const ::nlohmann::json &j, con
if (at.is_null()) if (at.is_null())
val = fallback; val = fallback;
else else
val = at.get<T::value_type>(); val = at.get<typename T::value_type>();
} }
} else { } else {
if (j.contains(key)) { if (j.contains(key)) {