diff --git a/include/tl/optional.hpp b/include/tl/optional.hpp index 9cba0b8..ad8ae2f 100644 --- a/include/tl/optional.hpp +++ b/include/tl/optional.hpp @@ -1982,15 +1982,12 @@ public: return *this; } - /// Constructs the value in-place, destroying the current one if there is - /// one. - template T &emplace(Args &&... args) noexcept { - static_assert(std::is_constructible::value, - "T must be constructible with Args"); - - *this = nullopt; - this->construct(std::forward(args)...); - return value(); + /// Rebinds this optional to `u`. + template >::value> + * = nullptr> + optional &emplace(U &&u) noexcept { + return *this = std::forward(u); } void swap(optional &rhs) noexcept { std::swap(m_value, rhs.m_value); }