Boost bind function
Posted
by Gokul
on Stack Overflow
See other posts from Stack Overflow
or by Gokul
Published on 2010-04-06T02:03:40Z
Indexed on
2010/04/06
2:13 UTC
Read the original article
Hit count: 518
Hi, I have a abstract base class A and a set of 10 derived classes. The infix operator is overloaded in all of the derived classes
class A{
void printNode( std::ostream& os )
{
this->printNode_p();
}
void printNode_p( std::ostream& os )
{
os << (*this);
}
};
There is a container which stores the base class pointers. I want to use boost::bind function to call the overloaded infix operator in each of its derived class. I have written like this
std::vector<A*> m_args
....
std::ostream os;
for_each( m_args.begin(), m_args.end(), bind(&A::printNode, _1, os) );
What is the problem with this code?
Thanks, Gokul.
© Stack Overflow or respective owner