summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools
diff options
context:
space:
mode:
authorAndrei Golubev <andrei.golubev@qt.io>2021-04-22 16:59:27 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2021-04-26 17:46:57 +0000
commite6436af8eb25312cb676436d5a04b85d9178346d (patch)
tree39dd4aa2a9c8960dd4609319be01e5ce26807e42 /src/corelib/tools
parent775a6329c8208a99af838159013fc20d006e8a13 (diff)
Add q_points_into_range to container utilities
We already used it in QString and QBA. And implicitly in QADP (see parent commit). Might as well move to a common location and reuse Change-Id: I694f0f1dbd109f17c134f64b3f3dc28d19556c88 Reviewed-by: Lars Knoll <lars.knoll@qt.io> (cherry picked from commit 10b46e7f0faecc42a94cc2e25ad3edd08ae28083) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'src/corelib/tools')
-rw-r--r--src/corelib/tools/qcontainertools_impl.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/corelib/tools/qcontainertools_impl.h b/src/corelib/tools/qcontainertools_impl.h
index 238e8a849b..465ea5c544 100644
--- a/src/corelib/tools/qcontainertools_impl.h
+++ b/src/corelib/tools/qcontainertools_impl.h
@@ -59,6 +59,19 @@ QT_BEGIN_NAMESPACE
namespace QtPrivate
{
+/*!
+ \internal
+
+ Returns whether \a p is within a range [b, e). In simplest form equivalent to:
+ b <= p < e.
+*/
+template<typename T, typename Cmp = std::less<>>
+static constexpr bool q_points_into_range(const T *p, const T *b, const T *e,
+ Cmp less = {}) noexcept
+{
+ return !less(p, b) && less(p, e);
+}
+
template <typename T, typename N>
void q_uninitialized_relocate_n(T* first, N n, T* out)
{