forked from boostorg/bind
Import of BoostBook documentation for any, array, bind, function, ref, and
signals libraries. [SVN r17866]
This commit is contained in:
222
doc/ref.xml
Normal file
222
doc/ref.xml
Normal file
@@ -0,0 +1,222 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE library PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN"
|
||||
"http://www.boost.org/tools/boostbook/dtd/boostbook.dtd">
|
||||
<library name="Ref" dirname="ref" id="ref" last-revision="$Date$">
|
||||
<libraryinfo>
|
||||
<author>
|
||||
<firstname>Jaakko</firstname>
|
||||
<surname>Järvi</surname>
|
||||
</author>
|
||||
<author>
|
||||
<firstname>Peter</firstname>
|
||||
<surname>Dimov</surname>
|
||||
</author>
|
||||
<author>
|
||||
<firstname>Douglas</firstname>
|
||||
<surname>Gregor</surname>
|
||||
</author>
|
||||
<author>
|
||||
<firstname>Dave</firstname>
|
||||
<surname>Abrahams</surname>
|
||||
</author>
|
||||
|
||||
<copyright>
|
||||
<year>1999</year>
|
||||
<year>2000</year>
|
||||
<holder>Jaakko Järvi</holder>
|
||||
</copyright>
|
||||
|
||||
<copyright>
|
||||
<year>2001</year>
|
||||
<year>2002</year>
|
||||
<holder>Peter Dimov</holder>
|
||||
</copyright>
|
||||
|
||||
<copyright>
|
||||
<year>2002</year>
|
||||
<holder>David Abrahams</holder>
|
||||
</copyright>
|
||||
|
||||
<legalnotice>
|
||||
<para>Permission to copy, use, modify, sell and distribute this
|
||||
software is granted provided this copyright notice appears in
|
||||
all copies. This software is provided "as is" without express
|
||||
or implied warranty, and with no claim as to its suitability for
|
||||
any purpose.
|
||||
</para>
|
||||
</legalnotice>
|
||||
|
||||
<librarypurpose>A utility library for passing references to generic functions</librarypurpose>
|
||||
<librarycategory name="category:higher-order"/>
|
||||
</libraryinfo>
|
||||
|
||||
<title>Boost.Ref</title>
|
||||
|
||||
<section id="ref.intro">
|
||||
<title>Introduction</title>
|
||||
|
||||
<using-namespace name="boost"/>
|
||||
|
||||
<para>The Ref library is a small library that is useful for passing
|
||||
references to function templates (algorithms) that would usually
|
||||
take copies of their arguments. It defines the class template
|
||||
<code><classname>boost::reference_wrapper<T></classname></code>,
|
||||
the two functions
|
||||
<code><functionname>boost::ref</functionname></code> and
|
||||
<code><functionname>boost::cref</functionname></code> that return
|
||||
instances of <code>boost::reference_wrapper<T></code>, and the
|
||||
two traits classes
|
||||
<code><classname>boost::is_reference_wrapper<T></classname></code>
|
||||
and
|
||||
<code><classname>boost::unwrap_reference<T></classname></code>.</para>
|
||||
|
||||
<para>The purpose of
|
||||
<code>boost::reference_wrapper<T></code> is to
|
||||
contain a reference to an object of type T. It is primarily used to
|
||||
"feed" references to function templates (algorithms) that take their
|
||||
parameter by value.</para>
|
||||
|
||||
<para>To support this usage,
|
||||
<code>boost::reference_wrapper<T></code> provides an implicit
|
||||
conversion to <code>T&</code>. This usually allows the function
|
||||
templates to work on references unmodified.</para>
|
||||
|
||||
<para><code>boost::reference_wrapper<T></code> is
|
||||
both CopyConstructible and Assignable (ordinary references are not
|
||||
Assignable).</para>
|
||||
|
||||
<para>The expression <code>boost::ref(x)</code>
|
||||
returns a
|
||||
<code>boost::reference_wrapper<X>(x)</code> where X
|
||||
is the type of x. Similarly,
|
||||
<code>boost::cref(x)</code> returns a
|
||||
<code>boost::reference_wrapper<X const>(x)</code>.</para>
|
||||
|
||||
<para>The expression
|
||||
<code>boost::is_reference_wrapper<T>::value</code>
|
||||
is true if T is a <code>reference_wrapper</code>, and
|
||||
false otherwise.</para>
|
||||
|
||||
<para>The type-expression
|
||||
<code>boost::unwrap_reference<T>::type</code> is T::type if T
|
||||
is a <code>reference_wrapper</code>, T otherwise.</para>
|
||||
</section>
|
||||
|
||||
<library-reference>
|
||||
<header name="boost/ref.hpp">
|
||||
<namespace name="boost">
|
||||
<class name="reference_wrapper">
|
||||
<template>
|
||||
<template-type-parameter name="T"/>
|
||||
</template>
|
||||
<purpose>
|
||||
Contains a reference to an object of type
|
||||
<computeroutput>T</computeroutput>.
|
||||
</purpose>
|
||||
|
||||
<para>
|
||||
<computeroutput><classname>reference_wrapper</classname></computeroutput>
|
||||
is primarily used to "feed" references to function templates
|
||||
(algorithms) that take their parameter by value. It provides
|
||||
an implicit conversion to
|
||||
<computeroutput>T&</computeroutput>, which usually allows
|
||||
the function templates to work on references unmodified.
|
||||
</para>
|
||||
|
||||
<typedef type="T" name="type"/>
|
||||
|
||||
<constructor>
|
||||
<parameter name="t">
|
||||
<paramtype>T&</paramtype>
|
||||
</parameter>
|
||||
|
||||
<effects><para>Constructs a
|
||||
<computeroutput><classname>reference_wrapper</classname></computeroutput>
|
||||
object that stores a reference to
|
||||
<computeroutput>t</computeroutput>.</para></effects>
|
||||
|
||||
<throws><para>Does not throw.</para></throws>
|
||||
</constructor>
|
||||
|
||||
<member-function-group name="access">
|
||||
<method name="conversion-operator" return-type="T&" cv="const">
|
||||
<returns><para>The stored reference.</para></returns>
|
||||
<throws><para>Does not throw.</para></throws>
|
||||
</method>
|
||||
|
||||
<method name="get" return-type="T&" cv="const">
|
||||
<returns><para>The stored reference.</para></returns>
|
||||
<throws><para>Does not throw.</para></throws>
|
||||
</method>
|
||||
|
||||
<method name="get_pointer" return-type="T*" cv="const">
|
||||
<returns><para>A pointer to the object referenced by the stored reference.</para></returns>
|
||||
<throws><para>Does not throw.</para></throws>
|
||||
</method>
|
||||
</member-function-group>
|
||||
|
||||
<free-function-group name="constructors">
|
||||
<function name="ref" return-type="reference_wrapper<T>">
|
||||
<parameter name="t">
|
||||
<paramtype>T&</paramtype>
|
||||
</parameter>
|
||||
|
||||
<returns><para><computeroutput><classname>reference_wrapper</classname><T>(t)</computeroutput></para></returns>
|
||||
|
||||
<throws><para>Does not throw.</para></throws>
|
||||
</function>
|
||||
|
||||
<function name="cref" return-type="reference_wrapper<T const>">
|
||||
<parameter name="t">
|
||||
<paramtype>T const&</paramtype>
|
||||
</parameter>
|
||||
|
||||
<returns><para><computeroutput><classname>reference_wrapper</classname><T const>(t)</computeroutput></para></returns>
|
||||
|
||||
<throws><para>Does not throw.</para></throws>
|
||||
</function>
|
||||
</free-function-group>
|
||||
</class>
|
||||
|
||||
<class name="is_reference_wrapper">
|
||||
<template>
|
||||
<template-type-parameter name="T"/>
|
||||
</template>
|
||||
|
||||
<purpose>Determine if a type <computeroutput>T</computeroutput> is an instantiation of <computeroutput><classname>reference_wrapper</classname></computeroutput>.</purpose>
|
||||
|
||||
<para>The <computeroutput>value</computeroutput> static constant will be <computeroutput>true</computeroutput> iff the type <computeroutput>T</computeroutput> is a specialization of <computeroutput><classname>reference_wrapper</classname></computeroutput>.</para>
|
||||
|
||||
<static-constant type="bool" name="value" value="unspecified"/>
|
||||
</class>
|
||||
|
||||
<class name="unwrap_reference">
|
||||
<template>
|
||||
<template-type-parameter name="T"/>
|
||||
</template>
|
||||
|
||||
<purpose>Find the type in a <computeroutput><classname>reference_wrapper</classname></computeroutput>.</purpose>
|
||||
|
||||
<para>The typedef <computeroutput>type</computeroutput> is <computeroutput>T::type</computeroutput> if <computeroutput>T</computeroutput> is a <computeroutput><classname>reference_wrapper</classname></computeroutput>, <computeroutput>T</computeroutput> otherwise.</para>
|
||||
|
||||
<typedef type="unspecified" name="T"/>
|
||||
</class>
|
||||
</namespace>
|
||||
</header>
|
||||
</library-reference>
|
||||
|
||||
<section id="ref.ack">
|
||||
<title>Acknowledgements</title>
|
||||
|
||||
<using-namespace name="boost"/>
|
||||
|
||||
<para><functionname>ref</functionname> and <functionname>cref</functionname>
|
||||
were originally part of the <libraryname>Tuple</libraryname> 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
|
||||
<classname>is_reference_wrapper</classname> and
|
||||
<classname>unwrap_reference</classname>.</para>
|
||||
</section>
|
||||
|
||||
</library>
|
Reference in New Issue
Block a user