diff --git a/sol/function.hpp b/sol/function.hpp index 264fc0e9..c6f47d89 100644 --- a/sol/function.hpp +++ b/sol/function.hpp @@ -61,6 +61,16 @@ public: function(const function&) = default; function& operator=(const function&) = default; + template + void operator()( Args&&... args ) { + call<>(std::forward(args)... ); + } + + template + auto operator()( types, Args&&... args ) { + return call(std::forward(args)... ); + } + template auto call(Args&&... args) -> decltype(invoke(types(), sizeof...(Args))) { push(); diff --git a/sol/table.hpp b/sol/table.hpp index 4a444e52..d3de9c48 100644 --- a/sol/table.hpp +++ b/sol/table.hpp @@ -82,13 +82,13 @@ public: } template - auto operator[](T&& key) -> decltype(proxy(*this, std::forward(key))) { - return proxy(*this, std::forward(key)); + proxy operator[](T&& key) { + return proxy(*this, std::forward(key)); } template - auto operator[](T&& key) const -> decltype(proxy(*this, std::forward(key))) { - return proxy(*this, std::forward(key)); + proxy operator[](T&& key) const { + return proxy(*this, std::forward(key)); } size_t size() const { diff --git a/tests.cpp b/tests.cpp index a24e92a4..6e7fdc6e 100644 --- a/tests.cpp +++ b/tests.cpp @@ -120,6 +120,7 @@ TEST_CASE("advanced/callLambdaReturns", "Checks for lambdas returning values") { lua.set_function("g", [ ] { return std::string("str"); }); lua.set_function("h", [ ] { }); lua.set_function("i", [ ] { return sol::nil; }); + //lua.set_function("i", [ ] { return std::make_tuple(1, 6.28f, 3.14, std::string("heh")); }); } TEST_CASE("advanced/callLambda2", "A C++ lambda is exposed to lua and called") {