2

我正在尝试创建一个简单的函数来进行简单的测试并返回真或假。

myfunct = (_3 < someArray[i]);

当我这样做时,我得到这个错误:

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

我希望得到与此等效的东西

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

2 回答 2

3

你确定你有正确的命名空间吗?

它应该是

using namespace boost::lambda;

或者

boost::lambda::_1

请记住,在 boost 的其他部分或其他库中使用了占位符(可能会与本​​地 TR1 发生冲突!),这可能会导致错误。

于 2010-01-13T14:14:04.687 回答
2

以下编译没有任何错误,您的其余代码如何?

#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]);
}
于 2010-01-13T14:23:25.837 回答