14 lines
572 B
Diff
14 lines
572 B
Diff
--- a/include/sol/optional_implementation.hpp
|
|
+++ b/include/sol/optional_implementation.hpp
|
|
@@ -2190,6 +2190,9 @@
|
|
template <class... Args>
|
|
T& emplace(Args&&... args) noexcept {
|
|
static_assert(std::is_constructible<T, Args&&...>::value, "T must be constructible with Args");
|
|
-
|
|
+
|
|
*this = nullopt;
|
|
- this->construct(std::forward<Args>(args)...);
|
|
+ // Reference specialization stores a pointer; set it directly.
|
|
+ // construct() only exists in the non-reference specialization.
|
|
+ m_value = std::addressof(std::forward<Args>(args)...);
|
|
+ return *m_value;
|