
I am having a problem with Boost.Bind (1.33.1). Consider the following simplified code: struct Bob { void func() { } }; void bob_test() { typedef std::map<int, Bob> BobMap; BobMap bob_map; std::for_each(bob_map.begin(), bob_map.end(), bind(&Bob::func, bind(&BobMap::value_type::second, _1))); } This fails to compile under DevStudio 8. The problem is the outer bound functor expects (Bob* const) but is passed (Bob const*). This seems a straight forward use -- call the "func" method on every Bob instance in the map. I can get this to compile if I change the inner bind to "bind<Bob&>(...)". Shouldn't the default return type of the binding of (R T::*) be (R&)? I looked through the bind and mem_fn documentation and didn't see any mention of that. The .* operator applied to a non-const T and a (R T::*) returns (R&), so it is implied that mem_fn of a data member does as well. Also, why does the error message refer to pointers and not references? Is that an artifact of compiler argument matching failure? Exact message: 1>inc\boost/bind/mem_fn_template.hpp(31) : error C2440: 'argument' : cannot convert from 'const Bob *' to 'Bob *const ' 1> inc\boost/bind/mem_fn_template.hpp(56) : see reference to function template instantiation 'R boost::_mfi::mf0<R,T>::call<const U>(U &,const T *) const' being compiled 1> with 1> [ 1> R=void, 1> T=Bob, 1> U=Bob 1> ]