使用可变参数存储C ++ lambda

我想创建一个具有以下机制的构造:

void some_func1();
void somt_func2(int, float = 3.14f);
enum { SIGNAL0, SIGNAL1 };

// connect
int con0 = connect(SIGNAL0, some_func1);
int con1 = connect(SIGNAL1, some_func2);
int con2 = connect(SIGNAL0, []{ /*some code*/ });
int con3 = connect(SIGNAL1, [](int, float){ /*some code*/ });

// invoke
invoke(SIGNAL0);
invoke(SIGNAL1, 123, 3.14f);

// would even be nice to be able to do this:
invoke(SIGNAL1, 123);

//the second float parameter gets default argument
// (probably not possible because of lambda can't have default args?)

函数connect(int,...?),invoke(int,...?)和存储的回调类型如何?

评论