Skip to content

Commit 839d988

Browse files
committed
Remove unnecessary field in optional
1 parent 65432b1 commit 839d988

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

runtime/core/portable_type/optional.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@ class optional final {
3737

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

4242
/// Constructs an optional object that matches the state of v.
4343
/* implicit */ optional(const optional<T>& v)
44-
: storage_(trivial_init), init_(v.init_) {
44+
: storage_(trivial_init_t{}), init_(v.init_) {
4545
if (init_) {
4646
new (&storage_.value_) T(v.storage_.value_);
4747
}
@@ -53,7 +53,7 @@ class optional final {
5353
/// Constructs an optional object from v.
5454
/* implicit */ optional(optional<T>&& v) noexcept(
5555
std::is_nothrow_move_constructible<T>::value)
56-
: storage_(trivial_init), init_(v.init_) {
56+
: storage_(trivial_init_t{}), init_(v.init_) {
5757
if (init_) {
5858
new (&storage_.value_) T(std::forward<T>(v.storage_.value_));
5959
}
@@ -134,8 +134,7 @@ class optional final {
134134
private:
135135
// Used to invoke the dummy ctor of storage_t in the initializer lists of
136136
// optional_base as default ctor is implicitly deleted because T is nontrivial
137-
struct trivial_init_t {
138-
} trivial_init{};
137+
struct trivial_init_t {};
139138

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

0 commit comments

Comments
 (0)