1

これを使っboost::bindboost::function使ってみました。些細な例のようですが、うまくいきません。手伝って頂けますか?

それは許可されていないからですか、それとも私は何か間違ったことをしているのですか?

// .h
class MyClass{
publc:
    void DoSomething( 
        const std::string& a,
        const std::string& b);
    void DoABind();

}

//.cpp
void MyClass::DoABind(){

    boost::function< void( const std::string& , const std::string& ) > callback( 
        boost::bind(
               &MyClass::DoSomething,
                 this ));

        // this line doesn't compile!!!
}
4

2 に答える 2

3

私はあなたが欲しいと思いますbind(&MyClass::DoSomething, this, _1, _2)。ただし、テストするブーストインストールはありません。

于 2010-05-11T15:06:02.143 に答える
3

パラメータプレースホルダーを使用するのを忘れました。これを試して:

boost::function< void( const std::string& , const std::string& ) > callback(
    boost::bind(
           &MyClass::DoSomething,
             this, _1, _2 ));

これは、ブースト1.41を使用してgcc4.4.1でコンパイルされます。

于 2010-05-11T15:06:12.640 に答える