aboutsummaryrefslogtreecommitdiff
path: root/lib/converters.h
diff options
context:
space:
mode:
authorKitsune Ral <Kitsune-Ral@users.sf.net>2018-07-08 09:02:23 +0900
committerKitsune Ral <Kitsune-Ral@users.sf.net>2018-07-08 09:02:23 +0900
commitcab30e850847ac221b08c3a8b715d0298bb63ddf (patch)
tree9bb3ccdbef0f706b2bacfe541466aedfe7bbc318 /lib/converters.h
parentab1f92a1eea2556f9ee6dd81f343c5b61f1b781c (diff)
downloadlibquotient-cab30e850847ac221b08c3a8b715d0298bb63ddf.tar.gz
libquotient-cab30e850847ac221b08c3a8b715d0298bb63ddf.zip
Move Omittable<> to util.h
Diffstat (limited to 'lib/converters.h')
-rw-r--r--lib/converters.h40
1 files changed, 0 insertions, 40 deletions
diff --git a/lib/converters.h b/lib/converters.h
index c01d7c8e..0b37fc48 100644
--- a/lib/converters.h
+++ b/lib/converters.h
@@ -56,46 +56,6 @@ class QVariant;
namespace QMatrixClient
{
- struct NoneTag {};
- constexpr NoneTag none {};
-
- /** A crude substitute for `optional` while we're not C++17
- *
- * Only works with default-constructible types.
- */
- template <typename T>
- class Omittable
- {
- public:
- explicit Omittable() : Omittable(none) { }
- Omittable(NoneTag) : _omitted(true) { }
- Omittable(const T& val) : _value(val) { }
- Omittable(T&& val) : _value(std::move(val)) { }
- Omittable<T>& operator=(const T& val)
- {
- _value = val;
- _omitted = false;
- return *this;
- }
- Omittable<T>& operator=(T&& val)
- {
- _value = std::move(val);
- _omitted = false;
- return *this;
- }
-
- bool omitted() const { return _omitted; }
- const T& value() const { return _value; }
- T& value() { return _value; }
- T&& release() { _omitted = true; return std::move(_value); }
-
- operator bool() const { return !omitted(); }
-
- private:
- T _value;
- bool _omitted = false;
- };
-
// This catches anything implicitly convertible to QJsonValue/Object/Array
inline auto toJson(const QJsonValue& val) { return val; }
inline auto toJson(const QJsonObject& o) { return o; }