相关疑难解决方法(0)

boost :: bind的返回类型是什么?

我想将函数的"binder"保存到变量中,通过利用其运算符重载工具在下面的代码中重复使用它.这是实际做我想要的代码:

#include <boost/bind.hpp>
#include <vector>
#include <algorithm>
#include <iostream>

class X 
{       
    int n; 
public: 
    X(int i):n(i){}
    int GetN(){return n;}  
};

int main()
{
    using namespace std;
    using namespace boost;

    X arr[] = {X(13),X(-13),X(42),X(13),X(-42)};
    vector<X> vec(arr,arr+sizeof(arr)/sizeof(X));

    _bi::bind_t<int, _mfi::mf0<int, X>, _bi::list1<arg<1> > > bindGetN = bind(&X::GetN,_1);

    cout << "With  n =13 : " 
         << count_if(vec.begin(),vec.end(),bindGetN == 13)
         << "\nWith |n|=13 : " 
         << count_if(vec.begin(),vec.end(),bindGetN == 13 || bindGetN == -13)
         << "\nWith |n|=42 : " 
         << count_if(vec.begin(),vec.end(),bindGetN == 42 || bindGetN …
Run Code Online (Sandbox Code Playgroud)

c++ types boost-bind

25
推荐指数
1
解决办法
8791
查看次数

标签 统计

boost-bind ×1

c++ ×1

types ×1