From 9d389aa1e3c9042d2a5909db6f9830360d1873eb Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Wed, 23 Jan 2002 21:04:00 +0000 Subject: [PATCH] account for new traits templates [SVN r12468] --- ref.html | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 53 insertions(+), 5 deletions(-) diff --git a/ref.html b/ref.html index 33757b8..a2cd7fc 100644 --- a/ref.html +++ b/ref.html @@ -35,8 +35,9 @@

The header boost/ref.hpp defines the class template -boost::reference_wrapper<T> and the two functions boost::ref and -boost::cref that return instances of boost::reference_wrapper<T>. +boost::reference_wrapper<T>, the two functions boost::ref and +boost::cref that return instances of +boost::reference_wrapper<T>, and the two traits classes boost::is_reference_wrapper<T> and boost::unwrap_reference<T>.

@@ -62,6 +63,14 @@ where X is the type of x. Similarly, boost::cref(x) returns a boost::reference_wrapper<X const>(x).

+

The expression boost::is_reference_wrapper<T>::value is +true if T is a +reference_wrapper, and false otherwise. + +

The type-expression boost::unwrap_reference<T>::type +is T::type if T is a +reference_wrapper, T otherwise. +

Interface

Synopsis

@@ -72,6 +81,8 @@ namespace boost template<class T> class reference_wrapper; template<class T> reference_wrapper<T> ref(T & t); template<class T> reference_wrapper<T const> cref(T const & t); + template<class T> class is_reference_wrapper<T const>; + template<class T> class unwrap_reference<T const>; } @@ -81,6 +92,7 @@ namespace boost template<class T> class reference_wrapper { public: + typedef T type; explicit reference_wrapper(T & t); @@ -92,30 +104,36 @@ public:

explicit reference_wrapper(T & t)

+

Effects: Constructs a reference_wrapper object that stores a reference to t.

Throws: Nothing.

+

operator T & () const

+

Returns: the stored reference.

Throws: Nothing.

+

T & get() const

+

Returns: the stored reference.

Throws: Nothing.

+

ref

@@ -123,12 +141,14 @@ public: template<class T> reference_wrapper<T> ref(T & t); +

Returns: reference_wrapper<T>(t).

Throws: Nothing.

+

cref

@@ -136,19 +156,47 @@ template<class T> reference_wrapper<T> ref(T & t); template<class T> reference_wrapper<T const> cref(T const & t); +

Returns: reference_wrapper<T const>(t).

Throws: Nothing.

+
+ +

is_reference_wrapper

+ +
+template<class T> class is_reference_wrapper<T const>
+{
+ public:
+    static bool value = unspecified;
+};
+
+Value is true iff T is a specialization of reference_wrapper. + +

unwrap_reference

+
+template<class T> class unwrap_reference<T const>
+{
+ public:
+    typedef unspecified type;
+};
+
+type is equivalent to T::type if T is a specialization of reference_wrapper. Otherwise type is equivalent to T.

Acknowledgements

-ref and cref were originally part of the Boost.Tuple library. -They were "promoted to boost:: status" because they are generally -useful. +ref and cref were originally part of the Boost.Tuple +library by Jaakko +Järvi. They were "promoted to boost:: status" by Peter Dimov because they are +generally useful. Douglas +Gregor and Dave +Abrahams contributed is_reference_wrapper and +unwrap_reference.