optional.patch 588 B

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