[Development] C++20 structural types (was: C++20 @ Qt)
Marc Mutz
marc.mutz at qt.io
Sat Nov 5 09:16:36 CET 2022
On 05.11.22 08:24, Marc Mutz via Development wrote:
> There's alsohttps://bugreports.qt.io/browse/QTBUG-94266
>
> I'll clone that for QFixed.
Done. Also for qfloat16.
I've also updated the epic
(https://bugreports.qt.io/browse/QTBUG-104180) with information
regarding wg21.link/P2484 which aims to remove the "public members"
restriction, and which we may want to wait for.
My head starts to fill with lots of examples of types that would be
useful as template arguments: QOSVersion, QTypeRevision, ...
Speaking of which, I've looked at QTypeRevision now. The relational
operators are very complex, indeed. I think that's because the encoding
of unspecified major/minor version doesn't match the desired ordering:
// major 0 < unspecified major < non-0 major
// minor 0 < unspecified minor < non-0 minor
yet
enum { SegmentUnknown = 0xff };
If the encoding was, instead,
optional<quint8> m{aj,in}orVersion() const {
switch (m_m{aj,in}or) {
case 0: return 0;
case 1: return std::nullopt;
default: return m_m{aj,in}or - 1;
}
we could probably = default op<=>. ... Ok, no, we'd also need to use
one uint16_t instead of two uint8_t's, because currently the
lexicographical sorting used by op<=> would be wrong for LE architectures.
Interestingly, the latter change could be done in a BC way, the former
cannot, though.
Thanks,
Marc
More information about the Development
mailing list