views:

58

answers:

2

I'm getting a compiler error with bind:

using namespace std;

bool odp(int arg1, int arg2);

// ...

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

My goal is to curry odp(), so its first argument is iValue, and apply that function in find_if.

The error:

C2065: '_1' : undeclared identifier.

What am I doing wrong?

+3  A: 

You need using namespace std::tr1::placeholders or using std::tr1::placeholders::_1.

James McNellis
A: 

2 things here.... 1st of all, it's entirely possible your compiler does not support TR1. Visual Studio 2008, for example, does not support TR1, unless you install Visual Studio 2008 Service Pack 1.

Second, I believe you need a namespace qualification for _1.

Billy ONeal