summarylogtreecommitdiffstats
path: root/sol2-fix-emplace.patch
blob: 9b10a37f2cd7ac2362ec0a9c258fb63dc20a5bce (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
From d805d027e0a0a7222e936926139f06e23828ce9f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E2=80=9CPaulo?= <paulo@ubook.com>
Date: Sat, 25 May 2024 01:52:59 -0300
Subject: [PATCH] fix emplace

---
 include/sol/optional_implementation.hpp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

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