首先,让我使用一些伪代码(JavaScript)来解释我想要实现的目标。
// Declare our function that takes a callback as as an argument, and calls the callback with true.
B(func) { func(true); }
// Call the function
B(function(bool success) { /* code that uses success */ });
我希望这已经说明了一切。如果还有不清楚的地方,请在我的问题下评论,以便我可以写更多内容来澄清我的问题。
我的要求是在C++中使用像这样的代码。
我尝试使用lambda函数,但我无法为其指定参数类型。
f
)以备后用,我该怎么做? - Issungstd::function
。 - greyfade