From ced142da92031be583557b52ac1f9096e2cb9027 Mon Sep 17 00:00:00 2001 From: Alexei Kotov Date: Tue, 11 Mar 2025 20:34:04 +0300 Subject: [PATCH] Lift upstream sol::optional::emplace Clang 19 build fix --- extern/sol3/README.md | 2 ++ extern/sol3/sol/optional_implementation.hpp | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/extern/sol3/README.md b/extern/sol3/README.md index 1674dcf599..202b2ca08b 100644 --- a/extern/sol3/README.md +++ b/extern/sol3/README.md @@ -1,3 +1,5 @@ The code in this directory is copied from https://github.com/ThePhD/sol2.git (64096348465b980e2f1d0e5ba9cbeea8782e8f27) +Additional changes include cherry-picking upstream commit d805d027e0a0a7222e936926139f06e23828ce9f to fix compilation under Clang 19. + License: MIT diff --git a/extern/sol3/sol/optional_implementation.hpp b/extern/sol3/sol/optional_implementation.hpp index b7673b17b1..a35df4ec87 100644 --- a/extern/sol3/sol/optional_implementation.hpp +++ b/extern/sol3/sol/optional_implementation.hpp @@ -2191,7 +2191,8 @@ namespace sol { static_assert(std::is_constructible::value, "T must be constructible with Args"); *this = nullopt; - this->construct(std::forward(args)...); + new (static_cast(this)) optional(std::in_place, std::forward(args)...); + return **this; } /// Swaps this optional with the other.