fork download
  1. #include <string>
  2.  
  3. int lua_getnumber() { return 42; }
  4. std::string lua_getstring() { return "foo"; }
  5.  
  6. namespace lua {
  7. template <typename T>
  8. T get();
  9.  
  10. template <>
  11. int get() { return lua_getnumber(); }
  12. template <>
  13. std::string get() { return lua_getstring(); }
  14. }
  15.  
  16. #include <iostream>
  17.  
  18. int main() {
  19. std::cout << lua::get<int>() << '\n';
  20. std::cout << lua::get<std::string>() << '\n';
  21. }
Success #stdin #stdout 0s 2984KB
stdin
Standard input is empty
stdout
42
foo