diff --git a/nebula_common/include/nebula_common/util/expected.hpp b/nebula_common/include/nebula_common/util/expected.hpp index 1d4333443..f4d8b2921 100644 --- a/nebula_common/include/nebula_common/util/expected.hpp +++ b/nebula_common/include/nebula_common/util/expected.hpp @@ -15,6 +15,7 @@ #pragma once #include +#include #include #include @@ -97,9 +98,10 @@ struct expected return default_; } - expected(const T & value) { value_ = value; } // NOLINT(runtime/explicit) - - expected(const E & error) { value_ = error; } // NOLINT(runtime/explicit) + expected(const T & value) : value_(value) {} // NOLINT(runtime/explicit) + expected(T && value) : value_(value) {} // NOLINT(runtime/explicit) + expected(const E & error) : value_(error) {} // NOLINT(runtime/explicit) + expected(E && error) : value_(error) {} // NOLINT(runtime/explicit) private: std::variant value_;