2

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]
}
Mathieu Pagé
  • 10,764
  • 13
  • 48
  • 71

2 Answers2

3

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
  • 55,802
  • 15
  • 111
  • 149
  • 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é Jan 13 '10 at 14:17
2

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
  • 10,547
  • 4
  • 53
  • 66