How can I store a boost::bind object as a class member?

前端 未结 4 1972
甜味超标
甜味超标 2020-12-21 00:45

I\'m writing an application that uses boost::asio. Asio\'s async_receive (or async_read) is invariably shown using a boost::bind

4条回答
  •  一整个雨季
    2020-12-21 01:07

    The return type of boost::bind is a boost::function. Here's a quick example using a very simple function:

    double f(int i, double d) { 
        cout << "int = " << i << endl; 
        return d; 
    } 
    
    boost::function bound_func = boost::bind(f, _1, 1.234); 
    int i = 99; 
    cout << bound_func(i) << endl;
    

    In your case the function has this type:

    boost::function f;
    

提交回复
热议问题