Commit 012c6a96 authored by EXT Arnaud Clère's avatar EXT Arnaud Clère
Browse files

Fixed potentially implicit bool conversions from fluent interface

parent 40d873d9
...@@ -259,7 +259,7 @@ public: ...@@ -259,7 +259,7 @@ public:
explicit QValueStatus(QAbstractValue* i) : impl(i) { Q_ASSERT(impl); } explicit QValueStatus(QAbstractValue* i) : impl(i) { Q_ASSERT(impl); }
QValueMode mode() const noexcept { return impl ? impl->mode() : QValueMode::Invalid; } QValueMode mode() const noexcept { return impl ? impl->mode() : QValueMode::Invalid; }
operator bool() const noexcept { return impl && impl->isValid(); } //!< Drives QTransmogrifier<T>::bind() traversal explicit operator bool() const noexcept { return impl && impl->isValid(); } //!< Drives QTransmogrifier<T>::bind() traversal
QValueStatus* operator ->() noexcept { return this; } QValueStatus* operator ->() noexcept { return this; }
QVal<QValueStatus> value() noexcept ; QVal<QValueStatus> value() noexcept ;
...@@ -332,7 +332,7 @@ public: ...@@ -332,7 +332,7 @@ public:
Q_ENABLE_MOVE_DEFAULT(QVal) Q_ENABLE_MOVE_DEFAULT(QVal)
explicit QVal(T_&& out) noexcept { std::swap(outer, out); } explicit QVal(T_&& out) noexcept { std::swap(outer, out); }
operator bool() const noexcept { return outer.operator bool(); } //!< Drives QTransmogrifier<T>::bind() traversal explicit operator bool() const noexcept { return outer.operator bool(); } //!< Drives QTransmogrifier<T>::bind() traversal
QValueStatus* operator->() noexcept { return outer.operator ->(); } QValueStatus* operator->() noexcept { return outer.operator ->(); }
QVal<T_> meta (QIdentifierLiteral& n, QAsciiData& m) { outer->_meta(n,m); return std::move(*this); } QVal<T_> meta (QIdentifierLiteral& n, QAsciiData& m) { outer->_meta(n,m); return std::move(*this); }
...@@ -381,7 +381,7 @@ public: ...@@ -381,7 +381,7 @@ public:
Q_ENABLE_MOVE_DEFAULT(QSeq) Q_ENABLE_MOVE_DEFAULT(QSeq)
explicit QSeq(T_&& out) noexcept { std::swap(outer, out); } explicit QSeq(T_&& out) noexcept { std::swap(outer, out); }
operator bool() const noexcept { return outer.operator bool(); } //!< Drives QTransmogrifier<T>::bind() traversal explicit operator bool() const noexcept { return outer.operator bool(); } //!< Drives QTransmogrifier<T>::bind() traversal
QValueStatus* operator->() noexcept { return outer.operator ->(); } QValueStatus* operator->() noexcept { return outer.operator ->(); }
operator QValueStatus() { return out(); /* calls T_::operator QValueStatus() if T_ != QValueStatus */ } operator QValueStatus() { return out(); /* calls T_::operator QValueStatus() if T_ != QValueStatus */ }
...@@ -426,7 +426,7 @@ public: ...@@ -426,7 +426,7 @@ public:
Q_ENABLE_MOVE_DEFAULT(QRec) Q_ENABLE_MOVE_DEFAULT(QRec)
explicit QRec(T_&& out) noexcept { std::swap(outer, out); } explicit QRec(T_&& out) noexcept { std::swap(outer, out); }
operator bool() const noexcept { return outer.operator bool(); } //!< Drives QTransmogrifier<T>::bind() traversal explicit operator bool() const noexcept { return outer.operator bool(); } //!< Drives QTransmogrifier<T>::bind() traversal
QValueStatus* operator->() noexcept { return outer.operator ->(); } QValueStatus* operator->() noexcept { return outer.operator ->(); }
operator QValueStatus() { return out(); /* calls T_::operator QValueStatus() if T_ != QValueStatus */ } operator QValueStatus() { return out(); /* calls T_::operator QValueStatus() if T_ != QValueStatus */ }
...@@ -479,7 +479,7 @@ struct QTransmogrifier { ...@@ -479,7 +479,7 @@ struct QTransmogrifier {
}; };
template<class T> template<class T>
bool QValueStatus::tryBind(BindGeneric, T&& t) { return QTransmogrifier<RemoveCvRef<T>>::zap(QValue(_unsafeCopy()),std::forward<T>(t)); } bool QValueStatus::tryBind(BindGeneric, T&& t) { return bool(QTransmogrifier<RemoveCvRef<T>>::zap(QValue(_unsafeCopy()),std::forward<T>(t))); }
// ////////////////////////////////////////////////////////////////////////// // //////////////////////////////////////////////////////////////////////////
// Base QAbstractValue implementations for Read and Write QValueMode // Base QAbstractValue implementations for Read and Write QValueMode
...@@ -937,9 +937,6 @@ struct QTransmogrifier<QDefaultValue<T>> { ...@@ -937,9 +937,6 @@ struct QTransmogrifier<QDefaultValue<T>> {
return r; return r;
} }
} }
static QValueStatus zap(QValue&& v, QDefaultValue<T>& t) {
return bind(std::move(v),std::move(t));
}
}; };
template<typename T> template<typename T>
......
...@@ -46,7 +46,7 @@ ...@@ -46,7 +46,7 @@
// Extensible set of QAbstractValue implementations providing concrete syntax to the logical data structure in a specific Mode among Write, Read, ... // Extensible set of QAbstractValue implementations providing concrete syntax to the logical data structure in a specific Mode among Write, Read, ...
#include "QJson_impl.h" // QJsonWriter, QJsonReader, QJsonBuilder, QJsonVisitor and QTransmogrifier<QJsonValue,_> support #include "QJson_impl.h" // QJsonWriter, QJsonReader, QJsonBuilder, QJsonVisitor and QTransmogrifier<QJsonValue> support
#include "QCbor_impl.h" // QCborWriter demonstrating the performance potential of the approach #include "QCbor_impl.h" // QCborWriter demonstrating the performance potential of the approach
#include "QData_impl.h" // QDataReader, QDataWriter demonstrating a QDataStream with implicit types for benchmarking #include "QData_impl.h" // QDataReader, QDataWriter demonstrating a QDataStream with implicit types for benchmarking
#include "QVariant_impl.h" // QVariantBuilder, QVariantVisitor and QTransmogrifier<QVariant,_> support #include "QVariant_impl.h" // QVariantBuilder, QVariantVisitor and QTransmogrifier<QVariant,_> support
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment