I am tring to port some code, that uses boost::unwrap_reference a lot to C++11. The code calls a lot member functions, like
template< typename T, typename Y>
void initialize( T _t, Y y)
{
typename boost::unwrap_reference< T >::type & t = _t;
t.doSomethingNastyWithY( y );
}
// The function is called like this
struct DoSomething
{
template<typename Y>
void doSomethingNastyWithY(Y y)
{
// do stuff
}
};
struct Object {};
DoSomething s;
Object obj;
int main()
{
initialize( s, obj ); // Take a copy of DoSomething
initialize( boost::ref(s), obj ); // Uses DoSomething as reference
}
I couldn’t find an equivalent to boost::unwrap_reference in the STL, is there an other straight forward way to do this?
EDIT: I clarified the example a bit
Something along the lines of:
Untested though, but that’s the gist of how you’d probably be able to do it.