diff options
author | Marc Mutz <marc.mutz@qt.io> | 2023-11-24 07:24:19 +0100 |
---|---|---|
committer | Ivan Solovev <ivan.solovev@qt.io> | 2023-12-05 22:56:45 +0100 |
commit | ee623402df0bb1903780d70a92efff65129adb5b (patch) | |
tree | c19feef33b5b403640843cfb4192b2b932b2b0be /src/corelib/global/qcomparehelpers.h | |
parent | 82a40f084b8ddb5f7f11d49f3296df9dba359301 (diff) |
tst_QCompareHelpers: extract Qt/std-mapping into public header
We'll need this elsehere, too.
Change-Id: I91a35a23dd201f7867898cee5b4d6743883f71fc
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Diffstat (limited to 'src/corelib/global/qcomparehelpers.h')
-rw-r--r-- | src/corelib/global/qcomparehelpers.h | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/corelib/global/qcomparehelpers.h b/src/corelib/global/qcomparehelpers.h index d0991e91b3..9c9da2c7d9 100644 --- a/src/corelib/global/qcomparehelpers.h +++ b/src/corelib/global/qcomparehelpers.h @@ -21,11 +21,40 @@ #ifdef __cpp_lib_three_way_comparison #include <compare> #endif +#include <QtCore/q20type_traits.h> #include <functional> // std::less QT_BEGIN_NAMESPACE +namespace QtOrderingPrivate { +#ifdef __cpp_lib_three_way_comparison + +template <typename QtOrdering> struct StdOrdering; +template <typename StdOrdering> struct QtOrdering; + +#define QT_STD_MAP(x) \ + template <> struct StdOrdering< Qt::x##_ordering> : q20::type_identity<std::x##_ordering> {};\ + template <> struct StdOrdering<std::x##_ordering> : q20::type_identity<std::x##_ordering> {};\ + template <> struct QtOrdering<std::x##_ordering> : q20::type_identity< Qt::x##_ordering> {};\ + template <> struct QtOrdering< Qt::x##_ordering> : q20::type_identity< Qt::x##_ordering> {};\ + /* end */ +QT_STD_MAP(partial) +QT_STD_MAP(weak) +QT_STD_MAP(strong) +#undef QT_STD_MAP + +template <typename In> constexpr auto to_std(In in) noexcept + -> typename QtOrderingPrivate::StdOrdering<In>::type +{ return in; } + +template <typename In> constexpr auto to_Qt(In in) noexcept + -> typename QtOrderingPrivate::QtOrdering<In>::type +{ return in; } + +#endif // __cpp_lib_three_way_comparison +} // namespace QtOrderingPrivate + /* For all the macros these parameter names are used: * LeftType - the type of the left operand of the comparison |