gpt4 book ai didi

c++ - 从 boost::function 中提取参数

转载 作者:行者123 更新时间:2023-11-30 03:40:32 27 4
gpt4 key购买 nike

我有这样的代码

int foo(int x) {
cout<<"Argument passed x = "<<x;
return x;
}
int main() {
boost::function<void ()> fn = boost::bind(foo, 10);
// can I get 10 out of fn object
// if (fn._1 == 10) {
// return;
//}
fn();
}

我想实现一个逻辑,即如果 fn - 第一个参数为 10,则不执行 fn。可能吗?

最佳答案

boost visit_each设施可能是门票 - 但因为它是实验性的和未记录的我没有更多信息......

哦等等,我知道:这实际上是你想要的 their example , compiled and executed on ideone.com , 显示。

关于c++ - 从 boost::function 中提取参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37930831/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com