Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qminmax.h
Go to the documentation of this file.
1// Copyright (C) 2022 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3// Qt-Security score:significant reason:default
4
5#ifndef QMINMAX_H
6#define QMINMAX_H
7
8#if 0
9#pragma qt_class(QtMinMax)
10#pragma qt_sync_stop_processing
11#endif
12
13#include <QtCore/qassert.h>
14#include <QtCore/qtconfigmacros.h>
15#include <QtCore/qttypetraits.h>
16
18
19template <typename T>
20constexpr inline const T &qMin(const T &a, const T &b) { return (a < b) ? a : b; }
21template <typename T>
22constexpr inline const T &qMax(const T &a, const T &b) { return (a < b) ? b : a; }
23template <typename T>
24constexpr inline const T &qBound(const T &min, const T &val, const T &max)
25{
26 Q_ASSERT(!(max < min));
27 return qMax(min, qMin(max, val));
28}
29template <typename T, typename U>
30constexpr inline QTypeTraits::Promoted<T, U> qMin(const T &a, const U &b)
31{
32 using P = QTypeTraits::Promoted<T, U>;
33 P _a = a;
34 P _b = b;
35 return (_a < _b) ? _a : _b;
36}
37template <typename T, typename U>
38constexpr inline QTypeTraits::Promoted<T, U> qMax(const T &a, const U &b)
39{
40 using P = QTypeTraits::Promoted<T, U>;
41 P _a = a;
42 P _b = b;
43 return (_a < _b) ? _b : _a;
44}
45template <typename T, typename U>
46constexpr inline QTypeTraits::Promoted<T, U> qBound(const T &min, const U &val, const T &max)
47{
48 Q_ASSERT(!(max < min));
49 return qMax(min, qMin(max, val));
50}
51template <typename T, typename U>
52constexpr inline QTypeTraits::Promoted<T, U> qBound(const T &min, const T &val, const U &max)
53{
54 using P = QTypeTraits::Promoted<T, U>;
55 Q_ASSERT(!(P(max) < P(min)));
56 return qMax(min, qMin(max, val));
57}
58template <typename T, typename U>
59constexpr inline QTypeTraits::Promoted<T, U> qBound(const U &min, const T &val, const T &max)
60{
61 using P = QTypeTraits::Promoted<T, U>;
62 Q_ASSERT(!(P(max) < P(min)));
63 return qMax(min, qMin(max, val));
64}
65
66QT_END_NAMESPACE
67
68#endif // QMINMAX_H
static std::unique_ptr< Grabber > create(QX11SurfaceCapture &capture, QScreen *screen)
const QVideoFrameFormat & format() const
QVideoFrame grabFrame() override
static std::unique_ptr< Grabber > create(QX11SurfaceCapture &capture, WId wid)
Combined button and popup list for selecting options.
#define qCDebug(category,...)
#define Q_STATIC_LOGGING_CATEGORY(name,...)
constexpr QTypeTraits::Promoted< T, U > qMin(const T &a, const U &b)
Definition qminmax.h:30
constexpr QTypeTraits::Promoted< T, U > qBound(const T &min, const T &val, const U &max)
Definition qminmax.h:52
constexpr QTypeTraits::Promoted< T, U > qBound(const T &min, const U &val, const T &max)
Definition qminmax.h:46
constexpr QTypeTraits::Promoted< T, U > qBound(const U &min, const T &val, const T &max)
Definition qminmax.h:59
constexpr const T & qBound(const T &min, const T &val, const T &max)
Definition qminmax.h:24
constexpr const T & qMax(const T &a, const T &b)
Definition qminmax.h:22
constexpr QTypeTraits::Promoted< T, U > qMax(const T &a, const U &b)
Definition qminmax.h:38