diff options
author | Lars Knoll <lars.knoll@qt.io> | 2020-06-05 21:01:29 +0200 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2020-07-08 14:13:56 +0200 |
commit | 0e2cfdedf261a9d29d7466bd26545549479d9f8a (patch) | |
tree | 8c6b3eaaad7463bf2e019b0694286aa065544138 /src/corelib/tools/qvarlengtharray.h | |
parent | 16bc995fd1eba4f7485226f319e7736ca19040bc (diff) |
Constrain the comparison operators for our container classes
This had already been in very few places, where we ran into issues with
this before. More generic constraints here will significantly reduce the
amount of error messages a user has to parse in case he tries to instantiate
an operator by accident (or with a lacking comparison operator for one of
it's template arguments).
Change-Id: I1521d19c55d99732d9742402bd534c390a8e4242
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/tools/qvarlengtharray.h')
-rw-r--r-- | src/corelib/tools/qvarlengtharray.h | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/corelib/tools/qvarlengtharray.h b/src/corelib/tools/qvarlengtharray.h index cea0e14d41..fccdfad081 100644 --- a/src/corelib/tools/qvarlengtharray.h +++ b/src/corelib/tools/qvarlengtharray.h @@ -605,7 +605,7 @@ Q_OUTOFLINE_TEMPLATE typename QVarLengthArray<T, Prealloc>::iterator QVarLengthA } template <typename T, qsizetype Prealloc1, qsizetype Prealloc2> -bool operator==(const QVarLengthArray<T, Prealloc1> &l, const QVarLengthArray<T, Prealloc2> &r) +QTypeTraits::compare_eq_result<T> operator==(const QVarLengthArray<T, Prealloc1> &l, const QVarLengthArray<T, Prealloc2> &r) { if (l.size() != r.size()) return false; @@ -616,13 +616,13 @@ bool operator==(const QVarLengthArray<T, Prealloc1> &l, const QVarLengthArray<T, } template <typename T, qsizetype Prealloc1, qsizetype Prealloc2> -bool operator!=(const QVarLengthArray<T, Prealloc1> &l, const QVarLengthArray<T, Prealloc2> &r) +QTypeTraits::compare_eq_result<T> operator!=(const QVarLengthArray<T, Prealloc1> &l, const QVarLengthArray<T, Prealloc2> &r) { return !(l == r); } template <typename T, qsizetype Prealloc1, qsizetype Prealloc2> -bool operator<(const QVarLengthArray<T, Prealloc1> &lhs, const QVarLengthArray<T, Prealloc2> &rhs) +QTypeTraits::compare_lt_result<T> operator<(const QVarLengthArray<T, Prealloc1> &lhs, const QVarLengthArray<T, Prealloc2> &rhs) noexcept(noexcept(std::lexicographical_compare(lhs.begin(), lhs.end(), rhs.begin(), rhs.end()))) { @@ -631,21 +631,21 @@ bool operator<(const QVarLengthArray<T, Prealloc1> &lhs, const QVarLengthArray<T } template <typename T, qsizetype Prealloc1, qsizetype Prealloc2> -inline bool operator>(const QVarLengthArray<T, Prealloc1> &lhs, const QVarLengthArray<T, Prealloc2> &rhs) +QTypeTraits::compare_lt_result<T> operator>(const QVarLengthArray<T, Prealloc1> &lhs, const QVarLengthArray<T, Prealloc2> &rhs) noexcept(noexcept(lhs < rhs)) { return rhs < lhs; } template <typename T, qsizetype Prealloc1, qsizetype Prealloc2> -inline bool operator<=(const QVarLengthArray<T, Prealloc1> &lhs, const QVarLengthArray<T, Prealloc2> &rhs) +QTypeTraits::compare_lt_result<T> operator<=(const QVarLengthArray<T, Prealloc1> &lhs, const QVarLengthArray<T, Prealloc2> &rhs) noexcept(noexcept(lhs < rhs)) { return !(lhs > rhs); } template <typename T, qsizetype Prealloc1, qsizetype Prealloc2> -inline bool operator>=(const QVarLengthArray<T, Prealloc1> &lhs, const QVarLengthArray<T, Prealloc2> &rhs) +QTypeTraits::compare_lt_result<T> operator>=(const QVarLengthArray<T, Prealloc1> &lhs, const QVarLengthArray<T, Prealloc2> &rhs) noexcept(noexcept(lhs < rhs)) { return !(lhs < rhs); |