【发布时间】:2015-06-29 03:10:52
【问题描述】:
我想通过模板(而不是通过函数)将函数(在编译时已知)传递给类。在课堂上,我想一个接一个地调用这些函数。这些函数始终具有相同的类型(在这种情况下返回 void 并且不传递任何参数)。稍后我想传递这样的函数: void foo(uint16_t arg);我尝试了两件事,但找不到解决方案。
typedef void(*decodeFunct)(void);
template <uint8_t pin, decodeFunct... functions>
class CIRLremote{
public:
CIRLremote(void){
// empty
}
void begin(void){
// call all decode functions
//functions... ();
call(functions...);
}
void call(decodeFunct f){
f();
}
};
【问题讨论】: