Hi All, 1) I don't understand this part of reference_wrapper: template<class T> class reference_wrapper { operator T& () const { return *t_; } }; Could someone please explain it? 2) Is there already a reference wrapper for n-ary functors which exposes the same result_type (if it exists) as the n-ary functor, but whose arguments types are arbitrary (deduced from the arguments)?
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Monday 03 August 2009, Igor R wrote:
1) I don't understand this part of reference_wrapper:
template<class T> class reference_wrapper { operator T& () const { return *t_; } };
Could someone please explain it?
reference_wrapper<T> is a functor that returns T&. This is exactly what operator() does.
That's not operator(), it's conversion to T&. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (GNU/Linux) iEYEARECAAYFAkp3AmYACgkQ5vihyNWuA4XU7gCfd3EHeajC45OF1zugyJwp7NJR ImgAn1ASVNk+/8AGdI+aVgt9qibTJwX2 =aoYZ -----END PGP SIGNATURE-----
Frank Mori Hess wrote:
That's not operator(), it's conversion to T&. -----BEGIN PGP SIGNATURE-----
Thanks, and for those coming after me with the same question: http://www.devx.com/tips/Tip/12459 Still hoping for an answer as to how to expose types such as result_type though.
participants (3)
-
er
-
Frank Mori Hess
-
Igor R