boost::bind
makes a copy of its inputs, so if boost::ref
is not used in this case, a copy of the chat_message
will be made. So it seems the authors of the code want to avoid that copy (at the cost of instantiating a boost::ref
object or two). This could make sense if chat_message
is large or expensive to copy. But it would make more sense to use a boost::cref
, since the original is passed by const reference, and the call should not modify the passed message.
Note: the above applies to std::bind
and std::tr1::bind
.