Hi, I have the following code:
template <typename T> LuaCall& operator>>(T) { BOOST_STATIC_ASSERT(sizeof(T) == 0); }
template <> LuaCall& operator>><int&>(int& val) { mResults.push_back(std::make_pair(LUA_RESULT_INTEGER, (void *)&val)); return *this; }
template <> LuaCall& operator>><float&>(float& val) { mResults.push_back(std::make_pair(LUA_RESULT_FLOAT, (void *)&val)); return *this; }
template <> LuaCall& operator>><double&>(double& val) { mResults.push_back(std::make_pair(LUA_RESULT_DOUBLE, (void *)&val)); return *this; }
template <> LuaCall& operator>><bool&>(bool& val) { mResults.push_back(std::make_pair(LUA_RESULT_BOOLEAN, (void *)&val)); return *this; }
template <> LuaCall& operator>><std::string&>(std::string& val) { mResults.push_back(std::make_pair(LUA_RESULT_STRING, (void *)&val)); return *this; }
template <> LuaCall& operator>><LuaNilStruct>(LuaNilStruct) { mResults.push_back(std::make_pair(LUA_RESULT_NIL, (void *)NULL)); return *this; }
And then:
int abc;
LuaCall(l, "test") % "test" % 5 % LuaNil % 2.333 >> abc;
I want it to work kinda like cin >> does, ie it needs to write to abc the return value of the lua function. So I need its address.. but it defaults on the default template. What am I doing wrong? There is surely a way to do this since cin does exactly that.
Thanks!
Note to whoever changed the %'s to >>: I changed it back since it's the way it is :D The code calls the Lua function test("test", 5, nil, 2.333) and saves its return value to abc. %'s are for the parameters of the functions, >>'s are for the return value(s).
template <typename T>
LuaCall& operator%(T val) {
mLua->Push(val);
++mArguments;
return *this;
}