enable move semantics when pushing rvalue optional

add forward_like-style cast to stack::pusher<optional<O>>
This commit is contained in:
Rohlem 2017-07-06 16:05:51 +02:00 committed by The Phantom Derpstorm
parent 958fd037ab
commit 077448bfc8

View File

@ -26,6 +26,7 @@
#include "raii.hpp"
#include "optional.hpp"
#include <memory>
#include <type_traits>
#ifdef SOL_CODECVT_SUPPORT
#include <codecvt>
#include <locale>
@ -703,7 +704,7 @@ namespace sol {
if (t == nullopt) {
return stack::push(L, nullopt);
}
return stack::push(L, t.value());
return stack::push(L, static_cast<std::conditional_t<std::is_lvalue_reference<T>::value, O&, O&&>>(t.value()));
}
};