cql parser: fix conversion from uninitalized<T> to optional<T> with gcc 9

We use uninitialized<T> (wrapping an optional<T>) to adjust to the
parser's way of laying out the code, but this fails with gcc 9
(presumably for the correct reasons) when converting from
uninitialized<T> back to optional<T>. Add a conversion operator
to make it build.
This commit is contained in:
Avi Kivity
2019-05-07 09:21:22 +03:00
parent a6759dc6aa
commit c26ec176dd

View File

@@ -125,6 +125,7 @@ struct uninitialized {
uninitialized& operator=(uninitialized&&) = default;
operator const T&() const & { return check(), *_val; }
operator T&&() && { return check(), std::move(*_val); }
operator std::optional<T>&&() && { return check(), std::move(_val); }
void check() const { if (!_val) { throw std::runtime_error("not intitialized"); } }
};