From f276dd5b7f8b45201949906c3167ff43ecb2caf4 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Fri, 27 Mar 2015 20:56:44 +0100 Subject: QVarLengthArray: add relational operators <,<=,>,>= std::vector has them, too. [ChangeLog][QtCore][QVarLengthArray] Added relational operators <, <=, >, >= if the element type supports operator<. Change-Id: I69e16d361fd4738a56b292ebfa78316d28871eda Reviewed-by: Thiago Macieira --- src/corelib/tools/qvarlengtharray.h | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'src/corelib/tools/qvarlengtharray.h') diff --git a/src/corelib/tools/qvarlengtharray.h b/src/corelib/tools/qvarlengtharray.h index 95cd0447d8..2d8f922cb8 100644 --- a/src/corelib/tools/qvarlengtharray.h +++ b/src/corelib/tools/qvarlengtharray.h @@ -480,6 +480,36 @@ bool operator!=(const QVarLengthArray &l, const QVarLengthArray +bool operator<(const QVarLengthArray &lhs, const QVarLengthArray &rhs) + Q_DECL_NOEXCEPT_EXPR(noexcept(std::lexicographical_compare(lhs.begin(), lhs.end(), + rhs.begin(), rhs.end()))) +{ + return std::lexicographical_compare(lhs.begin(), lhs.end(), + rhs.begin(), rhs.end()); +} + +template +inline bool operator>(const QVarLengthArray &lhs, const QVarLengthArray &rhs) + Q_DECL_NOEXCEPT_EXPR(noexcept(lhs < rhs)) +{ + return rhs < lhs; +} + +template +inline bool operator<=(const QVarLengthArray &lhs, const QVarLengthArray &rhs) + Q_DECL_NOEXCEPT_EXPR(noexcept(lhs < rhs)) +{ + return !(lhs > rhs); +} + +template +inline bool operator>=(const QVarLengthArray &lhs, const QVarLengthArray &rhs) + Q_DECL_NOEXCEPT_EXPR(noexcept(lhs < rhs)) +{ + return !(lhs < rhs); +} + QT_END_NAMESPACE #endif // QVARLENGTHARRAY_H -- cgit v1.2.3