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
q20atomic.h
Go to the documentation of this file.
1// Copyright (C) 2026 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 Q20ATOMIC_H
6#define Q20ATOMIC_H
7
8#include <QtCore/qtconfigmacros.h>
9
10#include <atomic>
11
12//
13// W A R N I N G
14// -------------
15//
16// This file is not part of the Qt API. Types and functions defined in this
17// file can reliably be replaced by their std counterparts, once available.
18// You may use these definitions in your own code, but be aware that we
19// will remove them once Qt depends on the C++ version that supports
20// them in namespace std. There will be NO deprecation warning, the
21// definitions will JUST go away.
22//
23// If you can't agree to these terms, don't use these definitions!
24//
25// We mean it.
26//
27
28QT_BEGIN_NAMESPACE
29
30namespace q20 {
31
32// This only ensures fixed initialization, nothing else (e.g. no wait/notify):
33#ifdef __cpp_lib_atomic_value_initialization
34template <class T>
35using atomic = std::atomic<T>;
36#else
37template <class T>
38class atomic : public std::atomic<T>
39{
40public:
41 using std::atomic<T>::atomic;
42 constexpr atomic() noexcept(noexcept(std::atomic<T>(T()))) : std::atomic<T>(T()) { }
43};
44
45template <class T>
46atomic(T) -> atomic<T>;
47#endif
48
49} // namespace q20
50
51QT_END_NAMESPACE
52
53#endif /* Q20ATOMIC_H */
constexpr atomic() noexcept(noexcept(std::atomic< T >(T())))
Definition q20atomic.h:42
atomic(T) -> atomic< T >