@@ -70,12 +70,12 @@ class OptionalStorage {
70
70
constexpr OptionalStorage () noexcept : empty() {}
71
71
72
72
constexpr OptionalStorage (OptionalStorage const &other) : OptionalStorage() {
73
- if (other.hasValue ()) {
73
+ if (other.has_value ()) {
74
74
emplace (other.val );
75
75
}
76
76
}
77
77
constexpr OptionalStorage (OptionalStorage &&other) : OptionalStorage() {
78
- if (other.hasValue ()) {
78
+ if (other.has_value ()) {
79
79
emplace (std::move (other.val ));
80
80
}
81
81
}
@@ -126,7 +126,7 @@ class OptionalStorage {
126
126
}
127
127
128
128
OptionalStorage &operator =(T const &y) {
129
- if (hasValue ()) {
129
+ if (has_value ()) {
130
130
val = y;
131
131
} else {
132
132
::new ((void *)std::addressof (val)) T (y);
@@ -135,7 +135,7 @@ class OptionalStorage {
135
135
return *this ;
136
136
}
137
137
OptionalStorage &operator =(T &&y) {
138
- if (hasValue ()) {
138
+ if (has_value ()) {
139
139
val = std::move (y);
140
140
} else {
141
141
::new ((void *)std::addressof (val)) T (std::move (y));
@@ -145,8 +145,8 @@ class OptionalStorage {
145
145
}
146
146
147
147
OptionalStorage &operator =(OptionalStorage const &other) {
148
- if (other.hasValue ()) {
149
- if (hasValue ()) {
148
+ if (other.has_value ()) {
149
+ if (has_value ()) {
150
150
val = other.val ;
151
151
} else {
152
152
::new ((void *)std::addressof (val)) T (other.val );
@@ -159,8 +159,8 @@ class OptionalStorage {
159
159
}
160
160
161
161
OptionalStorage &operator =(OptionalStorage &&other) {
162
- if (other.hasValue ()) {
163
- if (hasValue ()) {
162
+ if (other.has_value ()) {
163
+ if (has_value ()) {
164
164
val = std::move (other.val );
165
165
} else {
166
166
::new ((void *)std::addressof (val)) T (std::move (other.val ));
@@ -237,7 +237,7 @@ template <typename T> class OptionalStorage<T, true> {
237
237
}
238
238
239
239
OptionalStorage &operator =(T const &y) {
240
- if (hasValue ()) {
240
+ if (has_value ()) {
241
241
val = y;
242
242
} else {
243
243
::new ((void *)std::addressof (val)) T (y);
@@ -246,7 +246,7 @@ template <typename T> class OptionalStorage<T, true> {
246
246
return *this ;
247
247
}
248
248
OptionalStorage &operator =(T &&y) {
249
- if (hasValue ()) {
249
+ if (has_value ()) {
250
250
val = std::move (y);
251
251
} else {
252
252
::new ((void *)std::addressof (val)) T (std::move (y));
@@ -307,19 +307,19 @@ template <typename T> class Optional {
307
307
T &value () & { return Storage.getValue (); }
308
308
T &getValue () & { return Storage.getValue (); }
309
309
310
- constexpr explicit operator bool () const { return hasValue (); }
311
- constexpr bool has_value () const { return Storage.hasValue (); }
312
- constexpr bool hasValue () const { return Storage.hasValue (); }
310
+ constexpr explicit operator bool () const { return has_value (); }
311
+ constexpr bool has_value () const { return Storage.has_value (); }
312
+ constexpr bool hasValue () const { return Storage.has_value (); }
313
313
constexpr const T *operator ->() const { return getPointer (); }
314
314
T *operator ->() { return getPointer (); }
315
315
constexpr const T &operator *() const & { return getValue (); }
316
316
T &operator *() & { return getValue (); }
317
317
318
318
template <typename U> constexpr T value_or (U &&alt) const & {
319
- return hasValue () ? getValue () : std::forward<U>(alt);
319
+ return has_value () ? getValue () : std::forward<U>(alt);
320
320
}
321
321
template <typename U> constexpr T getValueOr (U &&alt) const & {
322
- return hasValue () ? getValue () : std::forward<U>(alt);
322
+ return has_value () ? getValue () : std::forward<U>(alt);
323
323
}
324
324
325
325
// / Apply a function to the value if present; otherwise return None.
@@ -335,10 +335,10 @@ template <typename T> class Optional {
335
335
T &&operator *() && { return std::move (Storage.getValue ()); }
336
336
337
337
template <typename U> T value_or (U &&alt) && {
338
- return hasValue () ? std::move (getValue ()) : std::forward<U>(alt);
338
+ return has_value () ? std::move (getValue ()) : std::forward<U>(alt);
339
339
}
340
340
template <typename U> T getValueOr (U &&alt) && {
341
- return hasValue () ? std::move (getValue ()) : std::forward<U>(alt);
341
+ return has_value () ? std::move (getValue ()) : std::forward<U>(alt);
342
342
}
343
343
344
344
// / Apply a function to the value if present; otherwise return None.
@@ -359,7 +359,7 @@ template <typename T, typename U>
359
359
constexpr bool operator ==(const Optional<T> &X, const Optional<U> &Y) {
360
360
if (X && Y)
361
361
return *X == *Y;
362
- return X.hasValue () == Y.hasValue ();
362
+ return X.has_value () == Y.has_value ();
363
363
}
364
364
365
365
template <typename T, typename U>
@@ -371,7 +371,7 @@ template <typename T, typename U>
371
371
constexpr bool operator <(const Optional<T> &X, const Optional<U> &Y) {
372
372
if (X && Y)
373
373
return *X < *Y;
374
- return X.hasValue () < Y.hasValue ();
374
+ return X.has_value () < Y.has_value ();
375
375
}
376
376
377
377
template <typename T, typename U>
@@ -414,7 +414,7 @@ template <typename T> constexpr bool operator<(const Optional<T> &, NoneType) {
414
414
}
415
415
416
416
template <typename T> constexpr bool operator <(NoneType, const Optional<T> &X) {
417
- return X.hasValue ();
417
+ return X.has_value ();
418
418
}
419
419
420
420
template <typename T>
0 commit comments