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
20QT_BEGIN_NAMESPACE
21
22namespace QtPrivate {
23template <typename T>
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
33template <typename T, QtPrivate::if_volatile<T> = true>
35 auto y = x;
36 ++y;
37 x = y;
38 return y;
39}
40
41template <typename T, QtPrivate::if_volatile<T> = true>
43{
44 auto y = x;
45 --y;
46 x = y;
47 return y;
48}
49} // namespace QtPrivate
50
51QT_END_NAMESPACE
52
53#endif // QVOLATILE_H
auto volatilePreDecrement(T &x)
Definition qvolatile_p.h:42
auto volatilePreIncrement(T &x)
Definition qvolatile_p.h:34