
15 Jul
2008
15 Jul
'08
7:28 p.m.
Michael Goldshteyn:
// This doesn't compile, however, even though the reference_wrapper class template has // an overloaded operator T& () const function
std::string colorFromConstRef2(boost::bind(&Crayon::GetColor,_1)(crefCr));
It doesn't because of the mem_fn behavior that bind inherits. The argument is not a reference to Crayon and so is assumed to be a smart pointer to Crayon. mem_fn then tries to invoke get_pointer() on it to obtain a Crayon*. You should be able to make it compile by adding a get_pointer overload for reference_wrapper: namespace boost { template<class T> T* get_pointer( reference_wrapper<T> const & r ) { return r.get_pointer(); } }