On Mon, Jun 13, 2011 at 9:55 AM, Robert Jones
<robertgbjones@gmail.com> wrote:
I thought understood what boost::reference_wrapper was all about, and in the context
of, say Boost.Bind, it seems pretty clear.
But why would you define a function to RETURN a reference_wrapper? eg
template <class T> struct X
{
std::pair<boost::reference_wrapper<T>, unsigned> getSomething(....) const;
};
I suspect I'm having a 'doh' moment here!
Thx,
In this particular case: it is possible to access first_type::type parameter. It depends what the caller expects from the static interface. Maybe there other types having getSomething(...) or other getSomething-overloads, which return std::pair template instantiations and all provide first_type::type. In such a case you don't have to apply additional meta-functions to grab the underlying type from the first_type. But there should be more info about the callers... On the other hand, callers can make specialized compile time dispatching for boost::reference_wrapper<T> but not T&.
With Kind Regards,
Ovanes