Advertisement
Guest User

Untitled

a guest
Aug 12th, 2017
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. template <typename T>
  2. T to_type(lua_State *L, int n)
  3. {
  4. return T();
  5. }
  6.  
  7. template <>
  8. double to_type<double>(lua_State *L, int n)
  9. {
  10. return lua_tonumber(L, n);
  11. }
  12.  
  13. template <>
  14. std::string to_type<std::string>(lua_State *L, int n)
  15. {
  16. return lua_tostring(L, n);
  17. }
  18.  
  19. template <>
  20. bool to_type<bool>(lua_State *L, int n)
  21. {
  22. return lua_toboolean(L, n);
  23. }
  24.  
  25. template <>
  26. int to_type<int>(lua_State *L, int n)
  27. {
  28. return lua_tonumber(L, n);
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement