diff --git a/optional.hpp b/optional.hpp index 20d176f..e8e3dd7 100644 --- a/optional.hpp +++ b/optional.hpp @@ -284,9 +284,9 @@ namespace tl { constexpr optional_storage_base() noexcept : m_dummy(), m_has_value(false) {} - template - constexpr optional_storage_base(in_place_t, U&& u) noexcept - : m_value(std::forward(u)), m_has_value(true) {} + template + constexpr optional_storage_base(in_place_t, U&&... u) noexcept + : m_value(std::forward(u)...), m_has_value(true) {} ~optional_storage_base() { if (m_has_value) { @@ -310,9 +310,9 @@ namespace tl { : m_dummy(), m_has_value(false) {} - template - constexpr optional_storage_base(in_place_t, U&& u) noexcept - : m_value(std::forward(u)), m_has_value(true) {} + template + constexpr optional_storage_base(in_place_t, U&&... u) noexcept + : m_value(std::forward(u)...), m_has_value(true) {} ~optional_storage_base() = default; @@ -351,10 +351,8 @@ namespace tl { } template constexpr explicit optional(enable_if_t::value, in_place_t>, - Args&&... args) { - this->m_has_value = true; - new (std::addressof(this->m_value)) T (std::forward(args)...); - } + Args&&... args) + : base(in_place, std::forward(args)...) {} template constexpr explicit optional( enable_if_t&, Args&&...>::value, in_place_t>,