mirror of
https://github.com/ThePhD/sol2.git
synced 2024-03-22 13:10:44 +08:00
Well, now that we've optimized l-values, the only reason for explicit_lua_func and member pointers is for it to actually store it. To we store a T
now, isntead of a T*
.
This commit is contained in:
parent
a66ceb92f7
commit
2d2ad59492
|
@ -186,23 +186,20 @@ struct explicit_lua_func<TFx, T, true> : public lua_func {
|
|||
typedef typename std::remove_pointer<typename std::decay<TFx>::type>::type fx_t;
|
||||
typedef detail::function_traits<fx_t> fx_traits;
|
||||
struct lambda {
|
||||
T* member;
|
||||
T member;
|
||||
TFx invocation;
|
||||
|
||||
template<typename... FxArgs>
|
||||
lambda(T* m, FxArgs&&... fxargs): member(m), invocation(std::forward<FxArgs>(fxargs)...) {}
|
||||
lambda(T m, FxArgs&&... fxargs): member(std::move(m)), invocation(std::forward<FxArgs>(fxargs)...) {}
|
||||
|
||||
template<typename... Args>
|
||||
typename fx_traits::return_type operator()(Args&&... args) {
|
||||
return ((*member).*invocation)(std::forward<Args>(args)...);
|
||||
return (member.*invocation)(std::forward<Args>(args)...);
|
||||
}
|
||||
} fx;
|
||||
|
||||
template<typename... FxArgs>
|
||||
explicit_lua_func(T* m, FxArgs&&... fxargs): fx(m, std::forward<FxArgs>(fxargs)...) {}
|
||||
|
||||
template<typename... FxArgs>
|
||||
explicit_lua_func(T& m, FxArgs&&... fxargs): fx(std::addressof(m), std::forward<FxArgs>(fxargs)...) {}
|
||||
explicit_lua_func(T m, FxArgs&&... fxargs): fx(std::move( m ), std::forward<FxArgs>(fxargs)...) {}
|
||||
|
||||
virtual int operator()(lua_State* L) override {
|
||||
return (*this)(tuple_types<typename fx_traits::return_type>(), typename fx_traits::args_type(), L);
|
||||
|
|
Loading…
Reference in New Issue
Block a user