
Hi, To be able to call a function object wrapped in boost::reference_wrapper<T>, we need something like the following: template< class T > inline typename boost::unwrap_reference<T>::type& unref( T& value ) { return static_cast<typename boost::unwrap_reference<Fun>::type&>(value); } which can then be used like template< class Fun > int algorithm( Fun fun ) { return unref(fun)(42); } any objections to adding this to ref.hpp? -Thorsten

Thorsten Ottosen wrote:
Hi,
To be able to call a function object wrapped in boost::reference_wrapper<T>, we need something like the following:
template< class T > inline typename boost::unwrap_reference<T>::type& unref( T& value ) { return static_cast<typename boost::unwrap_reference<Fun>::type&>(value); }
which can then be used like
template< class Fun > int algorithm( Fun fun ) { return unref(fun)(42); }
any objections to adding this to ref.hpp?
There's already unwrap_ref() which does exactly this. It doesn't seem to be documented though. -- Daniel Wallin BoostPro Computing http://www.boostpro.com
participants (2)
-
Daniel Wallin
-
Thorsten Ottosen