gpt4 book ai didi

c++ - 如何创建一个带有参数的函数,该参数将是 boost::bind 的结果?

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:21:51 24 4
gpt4 key购买 nike

所以我想创建一个像这样的函数:

void proxy_do_stuff(boost::bind return_here)
{
return_here(); // call stuff pased into boost::bind
}

我可以这样调用它:

proxy_do_stuff(boost::bind(&myclass::myfunction, this, my_function_argument_value, etc_fun_argument));

如何做这样的事情?

最佳答案

boost::bind 的返回类型是 boost::function 类型。见下文:

void proxy_do_stuff(boost::function<void()> return_here)
{
return_here(); // call stuff pased into boost::bind
}

关于c++ - 如何创建一个带有参数的函数,该参数将是 boost::bind 的结果?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7252964/

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