Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
Loading...
Searching...
No Matches
q26numeric.h
Go to the documentation of this file.
1
// Copyright (C) 2024 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
#
ifndef
Q26NUMERIC_H
5
#
define
Q26NUMERIC_H
6
7
#
include
<
QtCore
/
qglobal
.
h
>
8
9
//
10
// W A R N I N G
11
// -------------
12
//
13
// This file is not part of the Qt API. Types and functions defined in this
14
// file can reliably be replaced by their std counterparts, once available.
15
// You may use these definitions in your own code, but be aware that we
16
// will remove them once Qt depends on the C++ version that supports
17
// them in namespace std. There will be NO deprecation warning, the
18
// definitions will JUST go away.
19
//
20
// If you can't agree to these terms, don't use these definitions!
21
//
22
// We mean it.
23
//
24
25
#
include
<
numeric
>
26
#
include
<
limits
>
27
#
include
<
type_traits
>
28
29
QT_BEGIN_NAMESPACE
30
31
namespace
q26
{
32
33
// Like std::saturating_cast
34
#
if
defined
(
__cpp_lib_saturation_arithmetic
)
&&
__cpp_lib_saturation_arithmetic
>=
202603L
35
using
std
::
saturating_cast
;
36
#
else
37
template
<
typename
To,
typename
From>
38
constexpr
auto
saturating_cast
(From x)
39
{
40
static_assert
(
std
::is_integral_v<To>);
41
static_assert
(
std
::is_integral_v<From>);
42
43
[[maybe_unused]]
44
constexpr
auto
Lo = (
std
::numeric_limits<To>::min)();
45
constexpr
auto
Hi = (
std
::numeric_limits<To>::max)();
46
47
if
constexpr
(
std
::is_signed_v<From> ==
std
::is_signed_v<To>) {
48
// same signedness, we can accept regular integer conversion rules
49
return
x < Lo ? Lo :
50
x > Hi ? Hi :
51
/*else*/
To(x);
52
}
else
{
53
if
constexpr
(
std
::is_signed_v<From>) {
// ie. !is_signed_v<To>
54
if
(x < From{0})
55
return
To{0};
56
}
57
58
// from here on, x >= 0
59
using
FromU = std::make_unsigned_t<From>;
60
using
ToU = std::make_unsigned_t<To>;
61
return
FromU(x) > ToU(Hi) ? Hi : To(x);
// assumes Hi >= 0
62
}
63
}
64
#
endif
// __cpp_lib_saturation_arithmetic
65
66
template
<
typename
To,
typename
From>
67
constexpr
auto
saturate_cast
(From x)
68
{
69
return
q26
::saturating_cast<To>(x);
70
}
71
72
}
// namespace q26
73
74
QT_END_NAMESPACE
75
76
#
endif
/* Q26NUMERIC_H */
QEventDispatcherWin32Private
Definition
qeventdispatcher_win_p.h:112
QEventDispatcherWin32
Definition
qeventdispatcher_win_p.h:34
QZeroTimerEvent
Definition
qeventdispatcher_win_p.h:102
QZeroTimerEvent::QZeroTimerEvent
QZeroTimerEvent(int timerId)
Definition
qeventdispatcher_win_p.h:104
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qsequentialanimationgroup.cpp:47
q26
Definition
q26numeric.h:31
q26::saturate_cast
constexpr auto saturate_cast(From x)
Definition
q26numeric.h:67
q26::saturating_cast
constexpr auto saturating_cast(From x)
Definition
q26numeric.h:38
std
[33]
Definition
src_corelib_tools_qhash.cpp:421
qt_create_internal_window
static HWND qt_create_internal_window(const QEventDispatcherWin32 *eventDispatcher)
Definition
qeventdispatcher_win.cpp:278
qt_msectime
static quint64 qt_msectime()
Definition
qeventdispatcher_win.cpp:61
TIME_KILL_SYNCHRONOUS
#define TIME_KILL_SYNCHRONOUS
Definition
qeventdispatcher_win.cpp:24
WM_GESTURE
#define WM_GESTURE
Definition
qeventdispatcher_win.cpp:36
SendPostedEventsTimerId
@ SendPostedEventsTimerId
Definition
qeventdispatcher_win.cpp:50
WM_GESTURENOTIFY
#define WM_GESTURENOTIFY
Definition
qeventdispatcher_win.cpp:39
DWORD_PTR
#define DWORD_PTR
Definition
qeventdispatcher_win.cpp:56
WM_QT_ACTIVATENOTIFIERS
@ WM_QT_ACTIVATENOTIFIERS
Definition
qeventdispatcher_win.cpp:46
WM_QT_SOCKETNOTIFIER
@ WM_QT_SOCKETNOTIFIER
Definition
qeventdispatcher_win.cpp:44
WM_QT_SENDPOSTEDEVENTS
@ WM_QT_SENDPOSTEDEVENTS
Definition
qeventdispatcher_win.cpp:45
WM_TOUCH
#define WM_TOUCH
Definition
qeventdispatcher_win.cpp:32
isUserInputMessage
static bool isUserInputMessage(UINT message)
Definition
qeventdispatcher_win.cpp:463
calculateNextTimeout
static ULONG calculateNextTimeout(WinTimerInfo *t, quint64 currentTime)
Definition
qeventdispatcher_win.cpp:302
QSFDict
QHash< qintptr, QSockFd > QSFDict
Definition
qeventdispatcher_win_p.h:86
WinTimerDict
QHash< int, WinTimerInfo * > WinTimerDict
Definition
qeventdispatcher_win_p.h:109
QSNDict
QHash< qintptr, QSockNot * > QSNDict
Definition
qeventdispatcher_win_p.h:77
QSockFd
Definition
qeventdispatcher_win_p.h:79
QSockFd::selected
bool selected
Definition
qeventdispatcher_win_p.h:82
QSockFd::event
long event
Definition
qeventdispatcher_win_p.h:80
QSockFd::mask
long mask
Definition
qeventdispatcher_win_p.h:81
QSockFd::QSockFd
QSockFd(long ev=0, long ma=0)
Definition
qeventdispatcher_win_p.h:84
QSockNot
Definition
qeventdispatcher_win_p.h:73
QSockNot::fd
qintptr fd
Definition
qeventdispatcher_win_p.h:75
QSockNot::obj
QSocketNotifier * obj
Definition
qeventdispatcher_win_p.h:74
QWindowsMessageWindowClassContext
Definition
qeventdispatcher_win.cpp:231
QWindowsMessageWindowClassContext::~QWindowsMessageWindowClassContext
~QWindowsMessageWindowClassContext()
Definition
qeventdispatcher_win.cpp:268
QWindowsMessageWindowClassContext::atom
ATOM atom
Definition
qeventdispatcher_win.cpp:235
QWindowsMessageWindowClassContext::QWindowsMessageWindowClassContext
QWindowsMessageWindowClassContext()
Definition
qeventdispatcher_win.cpp:239
QWindowsMessageWindowClassContext::className
wchar_t * className
Definition
qeventdispatcher_win.cpp:236
WinTimerInfo
Definition
qeventdispatcher_win_p.h:88
WinTimerInfo::inTimerEvent
bool inTimerEvent
Definition
qeventdispatcher_win_p.h:96
WinTimerInfo::interval
qint64 interval
Definition
qeventdispatcher_win_p.h:89
WinTimerInfo::timerType
Qt::TimerType timerType
Definition
qeventdispatcher_win_p.h:94
WinTimerInfo::timeout
quint64 timeout
Definition
qeventdispatcher_win_p.h:90
WinTimerInfo::isSecondTimeout
bool isSecondTimeout
Definition
qeventdispatcher_win_p.h:98
WinTimerInfo::obj
QObject * obj
Definition
qeventdispatcher_win_p.h:92
WinTimerInfo::timerId
int timerId
Definition
qeventdispatcher_win_p.h:93
WinTimerInfo::dispatcher
QObject * dispatcher
Definition
qeventdispatcher_win_p.h:91
WinTimerInfo::usesExtendedInterval
bool usesExtendedInterval
Definition
qeventdispatcher_win_p.h:97
WinTimerInfo::fastTimerId
UINT fastTimerId
Definition
qeventdispatcher_win_p.h:95
qtbase
src
corelib
global
q26numeric.h
Generated on
for Qt by
1.18.0