以下を Ideone.com (および codepad.org) に入力しました。
#include <iostream>
#include <string>
#include <tr1/functional>
struct A {
A(const std::string& n) : name_(n) {}
void printit(const std::string& s)
{
std::cout << name_ << " says " << s << std::endl;
}
private:
const std::string name_;
};
int main()
{
A a("Joe");
std::tr1::function<void(const std::string&)> f = std::tr1::bind(&A::printit, &a, _1);
a("Hi");
}
そして、これらのエラーが発生しました:
prog.cpp: 関数 'int main()' 内:
prog.cpp:18: エラー: '_1' はこのスコープで宣言されていません
prog.cpp:19: エラー: '(A)(const char [3])' の呼び出しに一致しません</p>
prog.cpp:18: 警告: 未使用の変数 'f'</p>
私は一生、18行目の何が問題なのか理解できません。