Rapptz / sol

A C++11 Lua wrapper
MIT License
209 stars 32 forks source link

Stateless Userdata + Overloaded Functions #38

Closed ThePhD closed 10 years ago

ThePhD commented 10 years ago

Userdata's state is no longer kept in C++ and thus all userdata<T> C++ objects can be discarded after registration. Overloaded functions can now be disambiguated with the following syntax:

lua.set_function<int, int>( "my_func", overloaded_func ); 
// selects overload with 2 parameters, deduces return

lua.set_function<int(int, int)>( "my_func", overloaded_func ); 
// selects function with exact signature

lua.set_function<void(int)>( "my_func", overloaded_func ); 
// selects function with exact signature

lua.set_function<int>( "my_func", overloaded_func ); 
// selects version with has 1 parameter and deduces return