From e6436af8eb25312cb676436d5a04b85d9178346d Mon Sep 17 00:00:00 2001 From: Andrei Golubev Date: Thu, 22 Apr 2021 16:59:27 +0200 Subject: 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 (cherry picked from commit 10b46e7f0faecc42a94cc2e25ad3edd08ae28083) Reviewed-by: Qt Cherry-pick Bot --- src/corelib/tools/qcontainertools_impl.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/corelib/tools') 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> +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 void q_uninitialized_relocate_n(T* first, N n, T* out) { -- cgit v1.2.3