14 Jul
2014
14 Jul
'14
9:42 a.m.
On Monday 14 July 2014 12:13:44 Peter Dimov wrote:
Andrey Semashev wrote:
Why would you want r2? I mean, in what case would you intentionally write code to employ recursive references?
You don't write code to "employ recursive references". You write code that applies ref to an object of type T and stores the result in reference_wrapper<T>.
Would you expect this code to work: struct my_class { void bar(); }; struct my_class_const { void bar() const; }; template< typename T > void foo(T const& t) { typedef typename boost::unwrap_reference<T>::type class_type; boost::bind(&class_type::bar, boost::ref(t))(); } foo(my_class_const()); my_class x; foo(boost::ref(x));