From c9f7c084cfbdffc58a6d974e186e369d571c0bf7 Mon Sep 17 00:00:00 2001 From: Vas Crabb Date: Mon, 18 Nov 2024 06:02:09 +1100 Subject: [PATCH] Simplify sol::optional::emplace --- include/sol/optional_implementation.hpp | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/include/sol/optional_implementation.hpp b/include/sol/optional_implementation.hpp index e22226d6..dd9a2dd1 100644 --- a/include/sol/optional_implementation.hpp +++ b/include/sol/optional_implementation.hpp @@ -2186,12 +2186,8 @@ namespace sol { /// one. /// /// \group emplace - template - T& emplace(Args&&... args) noexcept { - static_assert(std::is_constructible::value, "T must be constructible with Args"); - - *this = nullopt; - new (static_cast(this)) optional(std::in_place, std::forward(args)...); + T& emplace(T& arg) noexcept { + m_value = &arg; return **this; }