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
qvolatile_p.h
Go to the documentation of this file.
1
// Copyright (C) 2021 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Marc Mutz <marc.mutz@kdab.com>
2
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4
#
ifndef
QVOLATILE_P_H
5
#
define
QVOLATILE_P_H
6
7
//
8
// W A R N I N G
9
// -------------
10
//
11
// This file is not part of the Qt API. It exists for the convenience
12
// of a number of Qt sources files. This header file may change from
13
// version to version without notice, or even be removed.
14
//
15
// We mean it.
16
//
17
18
#
include
<
QtCore
/
private
/
qglobal_p
.
h
>
19
20
QT_BEGIN_NAMESPACE
21
22
namespace
QtPrivate
{
23
template
<
typename
T
>
24
using
if_volatile
=
std
::
enable_if_t
<
std
::
is_volatile_v
<
T
>,
bool
>;
25
26
//
27
// C++20-deprecated volatile compound operations, rewritten as separated operations
28
//
29
30
// these functions return `auto`, not `T`, to strip cv-qualifiers without having
31
// to mention the `volatile` keyword
32
33
template
<
typename
T, QtPrivate::if_volatile<T> =
true
>
34
auto
volatilePreIncrement
(T &x) {
35
auto
y = x;
36
++y;
37
x = y;
38
return
y;
39
}
40
41
template
<
typename
T, QtPrivate::if_volatile<T> =
true
>
42
auto
volatilePreDecrement
(T &x)
43
{
44
auto
y = x;
45
--y;
46
x = y;
47
return
y;
48
}
49
}
// namespace QtPrivate
50
51
QT_END_NAMESPACE
52
53
#
endif
// QVOLATILE_H
QtPrivate
Definition
qalloc.h:27
QtPrivate::volatilePreDecrement
auto volatilePreDecrement(T &x)
Definition
qvolatile_p.h:42
QtPrivate::volatilePreIncrement
auto volatilePreIncrement(T &x)
Definition
qvolatile_p.h:34
qtbase
src
corelib
global
qvolatile_p.h
Generated on
for Qt by
1.14.0