Skip to content

Commit 5d2a1a2

Browse files
committed
Remove unnecessary field in optional
1 parent 65432b1 commit 5d2a1a2

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

runtime/core/portable_type/optional.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,16 @@ class optional final {
3333
using value_type = T;
3434

3535
/// Constructs an optional object that does not contain a value.
36-
/* implicit */ optional() noexcept : storage_(trivial_init), init_(false) {}
36+
/* implicit */ optional() noexcept
37+
: storage_(trivial_init_t{}), init_(false) {}
3738

3839
/// Constructs an optional object that does not contain a value.
3940
/* implicit */ optional(nullopt_t) noexcept
40-
: storage_(trivial_init), init_(false) {}
41+
: storage_(trivial_init_t{}), init_(false) {}
4142

4243
/// Constructs an optional object that matches the state of v.
4344
/* implicit */ optional(const optional<T>& v)
44-
: storage_(trivial_init), init_(v.init_) {
45+
: storage_(trivial_init_t{}), init_(v.init_) {
4546
if (init_) {
4647
new (&storage_.value_) T(v.storage_.value_);
4748
}
@@ -53,7 +54,7 @@ class optional final {
5354
/// Constructs an optional object from v.
5455
/* implicit */ optional(optional<T>&& v) noexcept(
5556
std::is_nothrow_move_constructible<T>::value)
56-
: storage_(trivial_init), init_(v.init_) {
57+
: storage_(trivial_init_t{}), init_(v.init_) {
5758
if (init_) {
5859
new (&storage_.value_) T(std::forward<T>(v.storage_.value_));
5960
}
@@ -134,8 +135,7 @@ class optional final {
134135
private:
135136
// Used to invoke the dummy ctor of storage_t in the initializer lists of
136137
// optional_base as default ctor is implicitly deleted because T is nontrivial
137-
struct trivial_init_t {
138-
} trivial_init{};
138+
struct trivial_init_t {};
139139

140140
/**
141141
* A wrapper type that lets us avoid constructing a T when there is no value.

0 commit comments

Comments
 (0)