C++ 如何将param作为右值的类成员函数绑定到boost::function?

C++ 如何将param作为右值的类成员函数绑定到boost::function?,c++,c++11,boost,rvalue-reference,rvalue,C++,C++11,Boost,Rvalue Reference,Rvalue,我尝试将参数为rval的类成员函数绑定到boost::function。 但它不起作用。 我的示例错误代码: class Class1 { int Foo1(int&& b) { return b; } void foo2() { boost::function<int(int&&)> fc(boost::bind(&Class1::Foo1, this, _1)

我尝试将参数为rval的类成员函数绑定到boost::function。 但它不起作用。 我的示例错误代码:

class Class1
{
    int Foo1(int&& b)
    {
        return b;
    }   

    void foo2()
    {
        boost::function<int(int&&)> fc(boost::bind(&Class1::Foo1, this, _1) 
    }   
};
Class1类
{
int Foo1(int&b)
{
返回b;
}   
void foo2()
{
boost::function fc(boost::bind(&Class1::Foo1,this,_1)
}   
};

使用lambda表达式:

boost::function<int(int&&)> fc = [this](int&& x)
{
    return Foo1(x);
};
boost::function fc=[this](int&&x)
{
返回Foo1(x);
};

它是如何工作的?请学习如何创建,并阅读。同时阅读所有内容以了解您的问题可能被否决的一些原因。例如,当问题陈述很简单时,很难提供解决方案。请您的问题更完整地描述您期望发生的情况以及两者之间的区别从实际结果中。请参阅,以获取关于什么是好的解释的提示。