/* Copyright (C) 2015 * swift project Community / Contributors * * This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level * directory of this distribution. No part of swift project, including this file, may be copied, modified, propagated, * or distributed except according to the terms contained in the LICENSE file. */ //! \file #ifndef BLACKMISC_COMPAREFUNCTIONS_H #define BLACKMISC_COMPAREFUNCTIONS_H #include #include #include namespace BlackMisc::Compare { //! Compare arithmetic values template , int> = 0> int compare(T a, T b) { if (a < b) { return -1; } if (b < a) { return 1; } return 0; } //! Compare enumerators template , int> = 0> int compare(T a, T b) { using UT = std::underlying_type_t; return compare(static_cast(a), static_cast(b)); } //! Compare QFlags template int compare(QFlags a, QFlags b) { using UT = typename QFlags::Int; return compare(static_cast(a), static_cast(b)); } //! Compare dates inline int compare(const QDateTime &a, const QDateTime &b) { return compare(a.toMSecsSinceEpoch(), b.toMSecsSinceEpoch()); } } // ns #endif