<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">https://github.com/ThePhD/sol2/commit/d805d027e0a0a7222e936926139f06e23828ce9f

From: =?UTF-8?q?=E2=80=9CPaulo?= &lt;paulo@ubook.com&gt;
Date: Sat, 25 May 2024 01:52:59 -0300
Subject: [PATCH] fix emplace

--- a/include/sol/optional_implementation.hpp
+++ b/include/sol/optional_implementation.hpp
@@ -2191,7 +2191,8 @@ namespace sol {
 			static_assert(std::is_constructible&lt;T, Args&amp;&amp;...&gt;::value, "T must be constructible with Args");
 
 			*this = nullopt;
-			this-&gt;construct(std::forward&lt;Args&gt;(args)...);
+			new (static_cast&lt;void*&gt;(this)) optional(std::in_place, std::forward&lt;Args&gt;(args)...);
+			return **this;
 		}
 
 		/// Swaps this optional with the other.
</pre></body></html>