clang: include/clang/Basic/CustomizableOptional.h Source File (original) (raw)
1
2
3
4
5
6
7
8
9#ifndef CLANG_BASIC_CUSTOMIZABLEOPTIONAL_H
10#define CLANG_BASIC_CUSTOMIZABLEOPTIONAL_H
11
12#include "llvm/ADT/Hashing.h"
13#include "llvm/Support/Compiler.h"
14#include "llvm/Support/type_traits.h"
15#include
16#include
17#include
18#include
19
21
22namespace optional_detail {
24}
25
26
27
30
31public:
33
36
39
41 : Storage(std::in_place, std::move(y)) {}
43
44 template <typename... ArgTypes>
46 : Storage(std::in_place, std::forward(Args)...) {}
47
48
53
55 Storage = std::move(y);
56 return *this;
57 }
59
60
61 template <typename... ArgTypes> void emplace(ArgTypes &&...Args) {
62 Storage.emplace(std::forward(Args)...);
63 }
64
66 Storage = y;
67 return *this;
68 }
70
71 void reset() { Storage.reset(); }
72
73 LLVM_DEPRECATED("Use &*X instead.", "&*X")
74 constexpr const T *getPointer() const { return &Storage.value(); }
75 LLVM_DEPRECATED("Use &*X instead.", "&*X")
77 LLVM_DEPRECATED("std::optional::value is throwing. Use *X instead", "*X")
78 constexpr const T &value() const & { return Storage.value(); }
79 LLVM_DEPRECATED("std::optional::value is throwing. Use *X instead", "*X")
80 T &value() & { return Storage.value(); }
81
82 constexpr explicit operator bool() const { return has_value(); }
83 constexpr bool has_value() const { return Storage.has_value(); }
84 constexpr const T *operator->() const { return &Storage.value(); }
86 constexpr const T &operator*() const & { return Storage.value(); }
88
89 template constexpr T value_or(U &&alt) const & {
91 }
92
93 LLVM_DEPRECATED("std::optional::value is throwing. Use *X instead", "*X")
94 T &&value() && { return std::move(Storage.value()); }
95 T &&operator*() && { return std::move(Storage.value()); }
96
97 template T value_or(U &&alt) && {
98 return has_value() ? std::move(operator*()) : std::forward(alt);
99 }
100};
101
102template
104
105template
107 return O ? llvm::hash_combine(true, *O) : llvm::hash_value(false);
108}
109
110template <typename T, typename U>
113 if (X && Y)
114 return *X == *Y;
115 return X.has_value() == Y.has_value();
116}
117
118template <typename T, typename U>
121 return !(X == Y);
122}
123
124template <typename T, typename U>
127 if (X && Y)
128 return *X < *Y;
129 return X.has_value() < Y.has_value();
130}
131
132template <typename T, typename U>
135 return !(Y < X);
136}
137
138template <typename T, typename U>
141 return Y < X;
142}
143
144template <typename T, typename U>
147 return !(X < Y);
148}
149
150template
152 return ;
153}
154
155template
157 return X == std::nullopt;
158}
159
160template
162 return !(X == std::nullopt);
163}
164
165template
167 return X != std::nullopt;
168}
169
170template
172 return false;
173}
174
175template
177 return X.has_value();
178}
179
180template
182 return !(std::nullopt < X);
183}
184
185template
187 return !(X < std::nullopt);
188}
189
190template
192 return std::nullopt < X;
193}
194
195template
197 return X < std::nullopt;
198}
199
200template
202 return std::nullopt <= X;
203}
204
205template
207 return X <= std::nullopt;
208}
209
210template
213}
214
215template
217 return Y && X == *Y;
218}
219
220template
222 return !(X == Y);
223}
224
225template
227 return !(X == Y);
228}
229
230template
232 return || *X < Y;
233}
234
235template
237 return Y && X < *Y;
238}
239
240template
242 return !(Y < X);
243}
244
245template
247 return !(Y < X);
248}
249
250template
252 return Y < X;
253}
254
255template
257 return Y < X;
258}
259
260template
262 return !(X < Y);
263}
264
265template
267 return !(X < Y);
268}
269
270}
271
272#endif
constexpr CustomizableOptional(std::in_place_t, ArgTypes &&...Args)
constexpr T value_or(U &&alt) const &
CustomizableOptional & operator=(const CustomizableOptional &O)=default
constexpr CustomizableOptional(T &&y)
void emplace(ArgTypes &&...Args)
Create a new object by constructing it in place with the given arguments.
constexpr bool has_value() const
constexpr CustomizableOptional(const CustomizableOptional &O)=default
constexpr CustomizableOptional(std::nullopt_t)
constexpr const T * operator->() const
CustomizableOptional & operator=(const T &y)
constexpr CustomizableOptional(std::optional< T > &&y)
constexpr const T & operator*() const &
CustomizableOptional & operator=(CustomizableOptional &&O)=default
CustomizableOptional & operator=(T &&y)
constexpr CustomizableOptional(const std::optional< T > &y)
constexpr const T & value() const &
constexpr CustomizableOptional()=default
constexpr CustomizableOptional(CustomizableOptional &&O)=default
constexpr const T * getPointer() const
constexpr CustomizableOptional(const T &y)
The JSON file list parser is used to communicate input to InstallAPI.
bool operator==(const CallGraphNode::CallRecord &LHS, const CallGraphNode::CallRecord &RHS)
bool operator<(DeclarationName LHS, DeclarationName RHS)
Ordering on two declaration names.
bool operator!=(CanQual< T > x, CanQual< U > y)
bool operator<=(DeclarationName LHS, DeclarationName RHS)
Ordering on two declaration names.
llvm::hash_code hash_value(const CustomizableOptional< T > &O)
bool operator>(DeclarationName LHS, DeclarationName RHS)
Ordering on two declaration names.
const FunctionProtoType * T
bool operator>=(DeclarationName LHS, DeclarationName RHS)
Ordering on two declaration names.
hash_code hash_value(const clang::tooling::dependencies::ModuleID &ID)