
best2=bind(&Node::value2, bind( &std::vector<Node>::at, //Ask for an element bind(&Node::children,_1), //Get the vector object 0 ) //Ask for element zero );
It's simple, compiler can't guess which function "at" you try to bind.
See overloading section of lambda documentation.
I couldn't see a section on overloading, or that dealt with this problem. Do you know the section number/title in the docs? Or perhaps it was an article somewhere else?
typedef std::vector<int> ints; typedef ints::const_reference ( ints::*ConstAtFunc ) (ints::size_type) const; Now call bind with ConstAtFunc( at ) as function
Thanks, that worked (and with operator[] as well): typedef std::vector<Node>::const_reference ( std::vector<Node>::*ConstVectorFunc ) (std::vector<Node>::size_type) const; best2=bind(&Node::value2, bind( ConstVectorFunc(&std::vector<Node>::at), bind(&Node::children,_1), 0 ) ); best2=bind(&Node::value2, bind( ConstVectorFunc(&std::vector<Node>::operator[]), bind(&Node::children,_1), 0 ) ); However I don't really understand what is going on. Is there a way to do this without using the typedef? I tried cref() around various parameters but cannot get that to compile. Darren