|
Boost Users : |
Subject: [Boost-users] lambda - if_then_else - Compiler can not deduce my Arguments
From: Simon Adler (boost_at_[hidden])
Date: 2011-03-28 05:34:45
Hello,
i need a hint about boost::bind and lambda.
Following (reduced) case:
class XML_Element
{
public:
const std::string & getName(void);
};
class HandleStuff
{
void handleTransformations( XML_Element * node );
void handleLinks( XML_Element * node );
void handle ( std::list<XML_Element *> * nodes )
{
// what i want to do via boost and which will do the job
for (std::list< XML_Element *>::iterator it = nodes->begin(); it !=
nodes->end(); it++)
{
if ( (*it)->getName() == "Transform" ) handleTransformations(*it);
else handleLinks(*it);
}
// what i tried
std::for_each( nodes->begin(); nodes->end(),
boost::lambda::if_then_else( boost::bind(&XML_Element::getName, _1) ==
std::string("Transform"),
boost::bind<void>(&HandleStuff::loadTransformations, this, _1),
boost::bind<void>(&HandleStuff::loadLinks, this, _1) )
}
}
got an error, that the compiler can not deduce a template Argument, but i do
not understand what
the compiler tries to say.
I am new to bind and lambda and i like it a lot, but in some cases the
Error-Messages are hard to
understand.
Thank you for any advice. Please understand, that this example is a reduced
Version what is realy
going on, so i only give the Functions Interfaces.
Simon
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