diff options
Diffstat (limited to 'lib/converters.h')
-rw-r--r-- | lib/converters.h | 32 |
1 files changed, 6 insertions, 26 deletions
diff --git a/lib/converters.h b/lib/converters.h index b753a80b..075af7ef 100644 --- a/lib/converters.h +++ b/lib/converters.h @@ -30,6 +30,7 @@ #include <vector> +#if QT_VERSION < QT_VERSION_CHECK(5,14,0) // Enable std::unordered_map<QString, T> // REMOVEME in favor of UnorderedMap, once we regenerate API files namespace std { @@ -37,15 +38,12 @@ template <> struct hash<QString> { size_t operator()(const QString& s) const Q_DECL_NOEXCEPT { - return qHash(s -#if (QT_VERSION >= QT_VERSION_CHECK(5, 6, 0)) - , - uint(qGlobalQHashSeed()) -#endif + return qHash(s, uint(qGlobalQHashSeed()) ); } }; } // namespace std +#endif class QVariant; @@ -206,7 +204,7 @@ template <typename T> struct JsonConverter<Omittable<T>> { static QJsonValue dump(const Omittable<T>& from) { - return from.omitted() ? QJsonValue() : toJson(from.value()); + return from.has_value() ? toJson(from.value()) : QJsonValue(); } static Omittable<T> load(const QJsonValue& jv) { @@ -378,28 +376,10 @@ namespace _impl { static void impl(ContT& container, const QString& key, const OmittableT& value) { - if (!value.omitted()) - addTo(container, key, value.value()); + if (value) + addTo(container, key, *value); } }; - -#if 0 - // This is a special one that unfolds optional<> - template <typename ValT, bool Force> - struct AddNode<optional<ValT>, Force> - { - template <typename ContT, typename OptionalT> - static void impl(ContT& container, - const QString& key, const OptionalT& value) - { - if (value) - AddNode<ValT>::impl(container, key, value.value()); - else if (Force) // Edge case, no value but must put something - AddNode<ValT>::impl(container, key, QString{}); - } - }; -#endif - } // namespace _impl static constexpr bool IfNotEmpty = false; |