c – std ::函数到成员函数

#include <functional>

struct A
{
    int func(int x, int y)
    {
        return x+y;
    }
};

int main()
{

    typedef std::function<int(int, int) > Funcp;
    A a;
    //Funcp func = std:::bind(&A::func, &a);
    Funcp func = std::bind(&A::func, a, std::placeholders::_1);


    return 0;
}

我在上面的绑定函数中得到错误:

 error C2825: '_Fty': must be a class or namespace when followed by '::'

语法错误在哪里?我使用visual studio 2010

Funcp func = std :: bind(& A :: func,& a,std :: placeholders :: _ 1,std :: placeholders :: _ 2);
http://stackoverflow.com/questions/5154116/stdfunction-to-member-function

本站文章除注明转载外,均为本站原创或编译
转载请明显位置注明出处:c – std ::函数到成员函数