views:

58

answers:

2

Hi, I'm trying to create a simple function that makes a simple test and return true or false.

myfunct = (_3 < someArray[i]);

When I do this, I get this error :

error: no match for 'operator<' in '<unnamed>::_1 < depths[i]'

What I hope is get something equivalent to this

bool myFunct(unsigned int a, unsigned int b, unsigned int c, unsigned int d)
{
   return c < 22; // Suppose 22 was in someArray[i]
}
+3  A: 

Are you sure you've got the namespaces right?

It should be either

using namespace boost::lambda;

or

boost::lambda::_1

Remember that placeholders are used in other parts of boost, or in other libraries (conflict with a local TR1 may happen!), which may induce errors.

Kornel Kisielewicz
Yes, I think it's my problem. I though about it on my way to work (after I posted this question), but could not test it because my code was at home. You just confirmed it. Thanks.
Mathieu Pagé
+2  A: 

The following compiles without any errors, how does the rest of your code look like?

#include <boost/function.hpp>
#include <boost/lambda/lambda.hpp>

using namespace boost;
using namespace boost::lambda;

int main(void)
{
    int someArray[5];
    int i;
    function<bool(int,int)> f = (_1 < someArray[i]);
}
Laurynas Biveinis
+1: for actual code -- no access to a compiler right now so I couldn't provide that :/
Kornel Kisielewicz