aboutsummaryrefslogtreecommitdiff
path: root/option.h
diff options
context:
space:
mode:
authorJohannes Stoelp <johannes.stoelp@gmail.com>2023-08-17 23:36:53 +0200
committerJohannes Stoelp <johannes.stoelp@gmail.com>2023-08-17 23:36:53 +0200
commit6c9695d16c157e9119dcf897266e8643e6565213 (patch)
tree6f96470fb1a56234f18c1561f3b96eb301fffe1c /option.h
parent851d4fb9db087eeb183f1c1cb5d96829a32e690b (diff)
downloadcpp-utils-6c9695d16c157e9119dcf897266e8643e6565213.tar.gz
cpp-utils-6c9695d16c157e9119dcf897266e8643e6565213.zip
enable misc-*,bugprone-* lints
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();
}