我有用于存储回调函数的结构,如下所示:
template<class T>
struct CommandGlobal : CommandBase
{
typedef boost::function<T ()> Command;
Command comm;
virtual T Execute() const
{
if(comm)
return comm();
return NULL;
}
};
Run Code Online (Sandbox Code Playgroud)
看起来它应该工作正常,除非T是无效的,因为Execute函数想要返回一个值..
这个问题的最佳解决方案是什么?
谢谢!