boost::bind upgrading from 1.33.1 to 1.34.1 problem, part2

Hello, Thanks Eric and Peter for the help with my previous question. Now I have another question. 1.34.1 does not allow me to compile the following code (it was fine on 1.33.1): struct CNode {void GetName(){}}; int main(int argc, char **argv){ typedef std::map<int, CNode> TPNodes; TPNodes Children; std::for_each( Children.begin(), Children.end(), boost::bind( &CNode::GetName, // Problem here boost::bind(&TPNodes::value_type::second,_1))); return 0; } I get this error: error C2440: 'argument' : cannot convert from 'const CNode *__w64 ' to 'CNode *const ' c:\src\boost_1_34_1\boost\bind\mem_fn_template.hpp 35 The code works if I have a map with pointers, but if I have instances then I have the error. It looks like I get a const value which was fine when a pointer was used. The question is how do I use algorithm on maps when I want to use only key or value? Thanks. -- Regards, Alexander. http://sjcomp.com

sj@sjcomp.com wrote:
Hello,
Thanks Eric and Peter for the help with my previous question. Now I have another question.
1.34.1 does not allow me to compile the following code (it was fine on 1.33.1): struct CNode {void GetName(){}}; int main(int argc, char **argv){ typedef std::map<int, CNode> TPNodes; TPNodes Children; std::for_each( Children.begin(), Children.end(), boost::bind( &CNode::GetName, // Problem here boost::bind(&TPNodes::value_type::second,_1))); return 0; }
I get this error: error C2440: 'argument' : cannot convert from 'const CNode *__w64 ' to 'CNode *const ' c:\src\boost_1_34_1\boost\bind\mem_fn_template.hpp 35
The inner boost::bind returns a const reference to a CNode, and GetName isn't const. Try boost::bind<CNode&>( &TPNodes::value_type::second, _1 ) I suspect that 1.33.1 was returning a copy of the CNode, allowing the code to compile, which is probably not what you wanted (but I'm not sure about that).
participants (2)
-
Peter Dimov
-
sj@sjcomp.com