From ee623402df0bb1903780d70a92efff65129adb5b Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Fri, 24 Nov 2023 07:24:19 +0100 Subject: tst_QCompareHelpers: extract Qt/std-mapping into public header We'll need this elsehere, too. Change-Id: I91a35a23dd201f7867898cee5b4d6743883f71fc Reviewed-by: Ivan Solovev --- src/corelib/global/qcomparehelpers.h | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'src/corelib/global/qcomparehelpers.h') 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 #endif +#include #include // std::less QT_BEGIN_NAMESPACE +namespace QtOrderingPrivate { +#ifdef __cpp_lib_three_way_comparison + +template struct StdOrdering; +template struct QtOrdering; + +#define QT_STD_MAP(x) \ + template <> struct StdOrdering< Qt::x##_ordering> : q20::type_identity {};\ + template <> struct StdOrdering : q20::type_identity {};\ + template <> struct QtOrdering : 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 constexpr auto to_std(In in) noexcept + -> typename QtOrderingPrivate::StdOrdering::type +{ return in; } + +template constexpr auto to_Qt(In in) noexcept + -> typename QtOrderingPrivate::QtOrdering::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 -- cgit v1.2.3