9#include <QtCore/qassert.h>
10#include <QtCore/qcompare.h>
11#include <QtCore/qcontainertools_impl.h>
12#include <QtCore/qmetatype.h>
13#include <QtCore/qtypeinfo.h>
25#ifndef QT_NO_DATASTREAM
33 template<
typename Integer>
35 std::is_integral<Integer>::value,
bool>
::type;
37 template<
typename Integer>
39 std::is_integral<Integer>::value
40 && (
sizeof(Integer) >
sizeof(
quint16)
41 || (
sizeof(Integer) ==
sizeof(
quint16)
42 && !std::is_signed<Integer>::value)),
bool>
::type;
44 template<
typename Integer, if_val
id_segment_type<Integer> = true>
49 && ((std::numeric_limits<Integer>::max)() < Integer(SegmentUnknown)
50 ||
segment < Integer(SegmentUnknown));
53 template<
typename Major,
typename Minor,
54 if_valid_segment_type<Major> =
true,
55 if_valid_segment_type<Minor> =
true>
63 template<
typename Major, if_val
id_segment_type<Major> = true>
70 template<
typename Minor, if_val
id_segment_type<Minor> = true>
77 template<
typename Integer, if_val
id_value_type<Integer> = true>
88 constexpr bool hasMajorVersion()
const {
return m_majorVersion != SegmentUnknown; }
91 constexpr bool hasMinorVersion()
const {
return m_minorVersion != SegmentUnknown; }
96 template<
typename Integer, if_val
id_value_type<Integer> = true>
99 return Integer(m_majorVersion << 8) | Integer(m_minorVersion);
103 friend constexpr bool
105 {
return lhs.toEncodedVersion<
quint16>() == rhs.toEncodedVersion<
quint16>(); }
111 auto cmpUnspecified = [](
quint8 leftVer,
quint8 rightVer) {
113 && (leftVer == QTypeRevision::SegmentUnknown
114 || rightVer == QTypeRevision::SegmentUnknown));
115 if (leftVer != QTypeRevision::SegmentUnknown)
120 if (lhs.hasMajorVersion() != rhs.hasMajorVersion()) {
121 return cmpUnspecified(lhs.majorVersion(), rhs.majorVersion());
124 if (is_eq(majorRes)) {
125 if (lhs.hasMinorVersion() != rhs.hasMinorVersion())
126 return cmpUnspecified(lhs.minorVersion(), rhs.minorVersion());
134 enum { SegmentUnknown = 0xff };
136#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN
138 : m_minorVersion(minor), m_majorVersion(major) {}
140 quint8 m_minorVersion = SegmentUnknown;
141 quint8 m_majorVersion = SegmentUnknown;
144 : m_majorVersion(major), m_minorVersion(minor) {}
146 quint8 m_majorVersion = SegmentUnknown;
147 quint8 m_minorVersion = SegmentUnknown;
154#ifndef QT_NO_DEBUG_STREAM
164#if !defined(QT_LEAN_HEADERS) || QT_LEAN_HEADERS < 2
166#include <QtCore/qversionnumber.h>
\inmodule QtCore\reentrant
static constexpr QTypeRevision fromMajorVersion(Major majorVersion)
Produces a QTypeRevision from the given majorVersion with an invalid minor version.
static constexpr QTypeRevision fromVersion(Major majorVersion, Minor minorVersion)
Produces a QTypeRevision from the given majorVersion and minorVersion, both of which need to be a val...
typename std::enable_if< std::is_integral< Integer >::value &&(sizeof(Integer) > sizeof(quint16)||(sizeof(Integer)==sizeof(quint16) &&!std::is_signed< Integer >::value)), bool >::type if_valid_value_type
static constexpr bool isValidSegment(Integer segment)
Returns true if the given number can be used as either major or minor version in a QTypeRevision.
static constexpr QTypeRevision fromMinorVersion(Minor minorVersion)
Produces a QTypeRevision from the given minorVersion with an invalid major version.
constexpr bool hasMinorVersion() const
Returns true if the minor version is known, otherwise false.
static constexpr QTypeRevision zero()
Produces a QTypeRevision with major and minor version {0}.
constexpr bool hasMajorVersion() const
Returns true if the major version is known, otherwise false.
constexpr quint8 minorVersion() const
Returns the minor version encoded in the revision.
friend constexpr Qt::strong_ordering compareThreeWay(const QTypeRevision &lhs, const QTypeRevision &rhs) noexcept
constexpr bool isValid() const
Returns true if the major version or the minor version is known, otherwise false.
typename std::enable_if< std::is_integral< Integer >::value, bool >::type if_valid_segment_type
static constexpr QTypeRevision fromEncodedVersion(Integer value)
Produces a QTypeRevision from the given value.
constexpr Integer toEncodedVersion() const
Transforms the revision into an integer value, encoding the minor version into the least significant ...
friend constexpr bool comparesEqual(const QTypeRevision &lhs, const QTypeRevision &rhs) noexcept
constexpr quint8 majorVersion() const
Returns the major version encoded in the revision.
constexpr QTypeRevision()=default
Produces an invalid revision.
\inmodule QtCore \title Classes and helpers for defining comparison operators \keyword qtcompare
static const strong_ordering greater
static const strong_ordering less
Combined button and popup list for selecting options.
constexpr Qt::strong_ordering compareThreeWay(LeftInt lhs, RightInt rhs) noexcept
#define Q_DECLARE_STRONGLY_ORDERED_LITERAL_TYPE(...)
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
static Q_CONSTINIT QBasicAtomicInteger< unsigned > seed
#define Q_DECLARE_TYPEINFO(TYPE, FLAGS)
Q_CORE_EXPORT QDataStream & operator>>(QDataStream &in, QTypeRevision &revision)
Q_CORE_EXPORT size_t qHash(const QTypeRevision &key, size_t seed=0)
Q_CORE_EXPORT QDataStream & operator<<(QDataStream &out, const QTypeRevision &revision)
QTextStream out(stdout)
[7]