get variant to easily get std::function from sol::function when using lua's call syntax.

This commit is contained in:
ThePhD 2014-05-30 15:30:14 -04:00
parent c85fe4dc95
commit 5d5ce9cd2e
2 changed files with 11 additions and 1 deletions

View File

@ -26,6 +26,7 @@
#include "tuple.hpp"
#include "stack.hpp"
#include <cstdint>
#include <functional>
namespace sol {
class function : public reference {
@ -79,6 +80,15 @@ public:
return invoke(types<Ret...>(), sizeof...(Args));
}
};
namespace stack {
namespace detail {
template <typename Signature>
inline std::function<Signature> get(types<std::function<Signature>>, lua_State* L, int index = -1) {
return std::function<Signature>(sol::function(L, index));
}
} // detail
} // stack
} // sol
#endif // SOL_FUNCTION_HPP

View File

@ -208,4 +208,4 @@ public:
};
} // sol
#endif // SOL_STATE_HPP
#endif // SOL_STATE_HPP