C ++:tr1 :: bind的麻烦(C2065)

时间:2010-06-15 23:47:28

标签: c++ syntax compiler-errors

我收到了bind的编译错误:

using namespace std;

bool odp(int arg1, int arg2);

// ...

find_if(vec.begin(), vec.end(), tr1::bind(odp, iValue, _1)); // C2065

我的目标是讨好odp(),因此它的第一个参数是iValue,并将该函数应用于find_if

错误:

C2065: '_1' : undeclared identifier.

我做错了什么?

2 个答案:

答案 0 :(得分:4)

您需要using namespace std::tr1::placeholdersusing std::tr1::placeholders::_1

答案 1 :(得分:1)

这里有两件事....首先,你的编译器完全有可能不支持TR1。例如,Visual Studio 2008不支持TR1,除非您安装Visual Studio 2008 Service Pack 1

其次,我认为您需要_1的命名空间资格。