4#ifndef QUNIQUEHANDLE_P_H
5#define QUNIQUEHANDLE_P_H
18#include <QtCore/qtconfigmacros.h>
19#include <QtCore/qassert.h>
20#include <QtCore/qcompare.h>
21#include <QtCore/qfunctionaltools_impl.h>
22#include <QtCore/qswap.h>
23#include <QtCore/qtclasshelpermacros.h>
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
150template <
typename HandleTraits>
157 if (handle != HandleTraits::invalidValue()) {
158 const bool success = HandleTraits::close(handle);
166template <
typename HandleTraits,
typename Deleter = QtUniqueHandleTraits::DefaultDeleter<HandleTraits>>
171 template <
typename D>
176 static_assert(
std::is_nothrow_default_constructible_v<
Type>);
177 static_assert(
std::is_nothrow_constructible_v<
Type>);
178 static_assert(
std::is_nothrow_copy_constructible_v<
Type>);
179 static_assert(
std::is_nothrow_move_constructible_v<
Type>);
180 static_assert(
std::is_nothrow_copy_assignable_v<
Type>);
181 static_assert(
std::is_nothrow_move_assignable_v<
Type>);
182 static_assert(
std::is_nothrow_destructible_v<
Type>);
183 static_assert(
std::is_nothrow_copy_constructible_v<Deleter>);
184 static_assert(
std::is_nothrow_move_constructible_v<Deleter>);
185 static_assert(
std::is_nothrow_copy_assignable_v<Deleter>);
186 static_assert(
std::is_nothrow_move_assignable_v<Deleter>);
187 static_assert(
std::is_nothrow_destructible_v<Deleter>);
188 static_assert(
noexcept(
std::declval<
Type>() ==
std::declval<
Type>()));
189 static_assert(
noexcept(
std::declval<
Type>() !=
std::declval<
Type>()));
190 static_assert(
noexcept(
std::declval<
Type>() <
std::declval<
Type>()));
191 static_assert(
noexcept(
std::declval<
Type>() <=
std::declval<
Type>()));
192 static_assert(
noexcept(
std::declval<
Type>() >
std::declval<
Type>()));
193 static_assert(
noexcept(
std::declval<
Type>() >=
std::declval<
Type>()));
195 template <if_default_constructible<Deleter> =
true>
220 qSwap(m_handle, other.m_handle);
221 qSwap(deleter(), other.deleter());
232 return m_handle != HandleTraits::invalidValue();
247 return Storage::object();
252 return Storage::object();
255 void reset(
const Type& handle = HandleTraits::invalidValue())
noexcept
257 if (handle == m_handle)
266 return std::exchange(m_handle, HandleTraits::invalidValue());
282 m_handle = HandleTraits::invalidValue();
294 if constexpr (
std::is_pointer_v<
Type>)
295 return qCompareThreeWay(Qt::totally_ordered_wrapper{ lhs.get() },
296 Qt::totally_ordered_wrapper{ rhs.get() });
308template <
typename Trait,
typename Deleter>
Type get() const noexcept
operator bool() const noexcept
friend Qt::strong_ordering compareThreeWay(const QUniqueHandle &lhs, const QUniqueHandle &rhs) noexcept
void swap(QUniqueHandle &other) noexcept
friend bool comparesEqual(const QUniqueHandle &lhs, const QUniqueHandle &rhs) noexcept
QUniqueHandle(const Type &handle=HandleTraits::invalidValue()) noexcept
QUniqueHandle(QUniqueHandle &&other) noexcept
bool isValid() const noexcept
const Deleter & deleter() const noexcept
~QUniqueHandle() noexcept
QUniqueHandle(const Type &handle, const Deleter &deleter) noexcept
void reset(const Type &handle=HandleTraits::invalidValue()) noexcept
QUniqueHandle(const Type &handle, Deleter &&deleter) noexcept
QUniqueHandle & operator=(const QUniqueHandle &)=delete
Type * operator&() noexcept
Deleter & deleter() noexcept
typename HandleTraits::Type Type
void swap(QUniqueHandle< Trait, Deleter > &lhs, QUniqueHandle< Trait, Deleter > &rhs) noexcept
void operator()(Type handle) const noexcept
typename HandleTraits::Type Type