私がメソッドを持っているとしましょう:
void foo(const std::string& s);
boost :: functionを作成できますか:
boost::function<void(const std::string&)> f = boost::bind(foo, temp);
f
ここで、tempは、が呼び出される前に削除されたchar*です。
私がメソッドを持っているとしましょう:
void foo(const std::string& s);
boost :: functionを作成できますか:
boost::function<void(const std::string&)> f = boost::bind(foo, temp);
f
ここで、tempは、が呼び出される前に削除されたchar*です。
はい。バインドは、char* を文字列に保持できること、または文字列に渡されることを認識できません。これを回避するには、次を使用します。
boost::bind(foo, std::string(temp));
temp が文字列としてバインダーにコピーされるようにします。
そして、これはあなたのためにコンパイルしていますか?そのはず
boost::function<void()> f = boost::bind(foo, std::string(temp));