|
Boost Users : |
From: yinglcs2_at_[hidden]
Date: 2006-02-15 13:42:57
I have code which calls unary_function with the
count_if() algorithm. Like this:
class do_hasContainerBlock : public
unary_function<BlockData*, bool>
{
public:
bool operator() (BlockData* bd) {
return bd->isContainer();
}
};
bool hasContainerBlock(list<BlockData*>& bdl) {
int count = count_if (bdl.begin(), bdl.end(),
do_hasContainerBlock());
return (count > 0);
}
And I would like to replace the unary function with
boost bind library, like this:
int count = count_if (bdl.begin(), bdl.end(),
bind( &BlockData::isContainer, _1) );
But this code does not copmile,I get this error:
g++ -O0 -g3 -Wall -c -fmessage-length=0
-oBlockDataUtils.o ../BlockDataUtils.cpp
../BlockDataUtils.cpp: In function âbool
hasContainerBlock(BlockDataList&)â:
../BlockDataUtils.cpp:95: error: no matching function
for call to âbind(<unknown type>, const
boost::lambda::lambda_functor<boost::lambda::placeholder<1>
>&)â
Can you please tell me how to fix that?
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net