【发布时间】:2014-06-12 11:31:14
【问题描述】:
我目前正在为函数创建模板,如果模板在特定类中,我需要一种方法,使函数中没有代码,我已经尝试过下面的内容,但我没想到它会起作用,它是 C++,太方便了 :P 其他人对我如何实现这一点有任何建议吗?
template<typename T> int Position::lSetPosition(lua_State* L){
#if T != Pro::Scene::Scene
auto p = Util::luaP_touserdata<T>(L, 1);
auto v = Math::Vector2(static_cast<int>(lua_tonumber(L, 2)),
static_cast<int>(lua_tonumber(L, 3)));
p->setPosition(v);
return 0;
#endif
}
【问题讨论】:
-
你为什么不专门为 Pro::Scene::Scene 做任何事情的模板?
标签: c++ templates c-preprocessor