diff --git a/examples/shared_ptr_modify_in_place.cpp b/examples/shared_ptr_modify_in_place.cpp index b61f14d8..d4eb82af 100644 --- a/examples/shared_ptr_modify_in_place.cpp +++ b/examples/shared_ptr_modify_in_place.cpp @@ -15,21 +15,21 @@ int main() { sol::state lua; - auto new_shared_ptr = [](sol::stack_object obj) { + auto new_shared_ptr = [](sol::stack_reference obj) { // works just fine sol::stack::modify_unique_usertype(obj, [](std::shared_ptr& sptr) { sptr = std::make_shared(sptr->value + 1); }); }; - auto reset_shared_ptr = [](sol::stack_object obj) { + auto reset_shared_ptr = [](sol::stack_reference obj) { sol::stack::modify_unique_usertype(obj, [](std::shared_ptr& sptr) { // THIS IS SUCH A BAD IDEA AAAGH sptr.reset(); // DO NOT reset to nullptr: // change it to an actual NEW value... // otherwise you will inject a nullptr into the userdata representation... - // which will NOT compare == to nil + // which will NOT compare == to Lua's nil }); }; diff --git a/sol/stack_core.hpp b/sol/stack_core.hpp index 1b81fa44..7632f82c 100644 --- a/sol/stack_core.hpp +++ b/sol/stack_core.hpp @@ -872,7 +872,7 @@ namespace sol { } template - inline void modify_unique_usertype_as(stack_object obj, F&& f) { + inline void modify_unique_usertype_as(const stack_reference& obj, F&& f) { typedef unique_usertype_traits u_traits; void* raw = lua_touserdata(obj.lua_state(), obj.stack_index()); void* ptr_memory = detail::align_usertype_pointer(raw); @@ -883,7 +883,7 @@ namespace sol { } template - inline void modify_unique_usertype(stack_object obj, F&& f) { + inline void modify_unique_usertype(const stack_reference& obj, F&& f) { typedef meta::bind_traits> bt; typedef typename bt::template arg_at<0> T; modify_unique_usertype_as>(obj, std::forward(f));