aboutsummaryrefslogtreecommitdiff
path: root/option.h
diff options
context:
space:
mode:
Diffstat (limited to 'option.h')
-rw-r--r--option.h8
1 files changed, 4 insertions, 4 deletions
diff --git a/option.h b/option.h
index ab7a72e..47a0624 100644
--- a/option.h
+++ b/option.h
@@ -33,20 +33,20 @@ struct option {
constexpr option(const option& op) : m_has_value{op.has_value()} {
if (op.has_value()) {
// Copy construct from inner VALUE of OP.
- new (m_value) T(op.value());
+ new (&m_value) T(op.value());
}
}
constexpr option(option&& op) noexcept : m_has_value{op.has_value()} {
if (op.m_has_value) {
// Move construct from inner VALUE of OP.
- new (m_value) T(std::move(op.take()));
+ new (&m_value) T(std::move(op.take()));
}
}
template <typename U = T>
constexpr option(T&& val) : m_has_value{true} {
- new (m_value) T(std::move(val));
+ new (&m_value) T(std::move(val));
}
// -- DESTRUCTOR -------------------------------------------------------------
@@ -60,7 +60,7 @@ struct option {
template <typename... Params>
constexpr T& emplace(Params&&... params) {
reset();
- new (m_value) T(std::forward<Params>(params)...);
+ new (&m_value) T(std::forward<Params>(params)...);
m_has_value = true;
return value();
}