summaryrefslogtreecommitdiffstats
path: root/src/corelib/global/qcompare_impl.h
Commit message (Collapse)AuthorAgeFilesLines
* Break cyclic includes in qglobal.h [2/3]Ahmad Samir2023-05-261-4/+5
| | | | | | Task-number: QTBUG-106722 Change-Id: I6cf2b3fcd419659cc8a0633892393febd26e505b Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* CompareAgainstLiteralZero: fix SFINAE considerationsDennis Oberst2023-05-251-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | This issue arose during the comparison of two different ordering types. When comparing QPartialOrdering::Less to QStrongOrdering::Less, an unintended overload was considered due to the SFINAE ctor-overload of CompareAgainstLiteralZero. For example: static_assert(QPartialOrdering::Less == QStrongOrdering::Less); would consider: friend constexpr bool operator==(QtPrivate::CompareAgainstLiteralZero, QStrongOrdering rhs) noexcept as an overload. To address this, a stricter approach is now used by triggering the SFINAE-check on std::nullptr_t instead. This resolves the ambiguity while still rejecting std::nullptr_t as intended. As the compiler is unable to resolve this automatically, this refactoring is required. Pick-to: 6.5 6.2 Change-Id: I9ab7e55d2822980198f38f5a66143387999a4d94 Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
* Use SPDX license identifiersLucie Gérard2022-05-161-38/+2
| | | | | | | | | | | | | Replace the current license disclaimer in files by a SPDX-License-Identifier. Files that have to be modified by hand are modified. License files are organized under LICENSES directory. Task-number: QTBUG-67283 Change-Id: Id880c92784c40f3bbde861c0d93f58151c18b9f1 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* Long live QT_TYPESAFE_FLAGS!Giuseppe D'Angelo2021-06-231-0/+69
This commit adds an opt-in mechanism to kill type-unsafe functions and implicit conversions of QFlags, therefore removing an entire category of bugs that QFlags itself is supposed to protect against: QFlags<E> f; f == 3.14; // OK; f->int, int->double, then operator==(double,double) f & UnrelatedEnum; // OK if of unscoped enum, calls operator&(int) f &= 123; // calls QFlags::operator&=(int) int i = f * 42; // f->int, then operator*(int, int) Thankfully, operator+ and operator- had already been deleted. By defining QT_TYPESAFE_FLAGS one: * disables operators taking (u)int, forcing the usage of an enumeration or another QFlags object; * turns the implicit conversions towards integers/bool in explicit (one can always use fromInt/toInt instead); * adds a convenience set of (in)equality operators against literal 0, in order to keep code like `(flag & bit) == 0` compile. This set can't be added normally otherwise it would add ambiguity; * adds the unary operator~(Enum), turning it into a flag. This is a source incompatible change, in general, so it's opt-in. This is a Qt-internal macro at this point. It can't be offered to users yet because we need to fix some public API flaws first: in some places (e.g. QPainter::drawText) we ask users to do type-unsafe manipulation of flags. A user enabling the macro wouldn't be able to properly use the functions in question. This macro will be enabled in a follow-up commit. Change-Id: I796f2256b446bafc12cdcbaf7de417d12bd3619e Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>