File: ref.xml

package info (click to toggle)
boost1.35 1.35.0-5
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 203,856 kB
  • ctags: 337,867
  • sloc: cpp: 938,683; xml: 56,847; ansic: 41,589; python: 18,999; sh: 11,566; makefile: 664; perl: 494; yacc: 456; asm: 353; csh: 6
file content (240 lines) | stat: -rw-r--r-- 8,502 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
<?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: 2006-11-10 13:27:05 -0500 (Fri, 10 Nov 2006) $">
  <libraryinfo>
    <author>
      <firstname>Jaakko</firstname>
      <surname>J&auml;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&auml;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>Subject to the Boost Software License, Version 1.0. See 
      accompanying file <filename>LICENSE_1_0.txt</filename> or copy at
      <ulink url="http://www.boost.org/LICENSE_1_0.txt">http://www.boost.org/LICENSE_1_0.txt</ulink>.
      </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&lt;T&gt;</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&lt;T&gt;</code>, and the
  two traits classes
  <code><classname>boost::is_reference_wrapper&lt;T&gt;</classname></code>
  and
  <code><classname>boost::unwrap_reference&lt;T&gt;</classname></code>.</para>

  <para>The purpose of
  <code>boost::reference_wrapper&lt;T&gt;</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&lt;T&gt;</code> provides an implicit
  conversion to <code>T&amp;</code>. This usually allows the function
  templates to work on references unmodified.</para>

  <para><code>boost::reference_wrapper&lt;T&gt;</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&lt;X&gt;(x)</code> where X
  is the type of x. Similarly,
  <code>boost::cref(x)</code> returns a
  <code>boost::reference_wrapper&lt;X const&gt;(x)</code>.</para>

  <para>The expression
  <code>boost::is_reference_wrapper&lt;T&gt;::value</code>
  is true if T is a <code>reference_wrapper</code>, and
  false otherwise.</para>

  <para>The type-expression
  <code>boost::unwrap_reference&lt;T&gt;::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>

      <description>
        <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&amp;</computeroutput>, which usually allows
        the function templates to work on references
        unmodified.</para>
      </description>

      <typedef name="type"><type>T</type></typedef>

      <constructor specifiers="explicit">
        <parameter name="t">
          <paramtype>T&amp;</paramtype>
        </parameter>

        <effects><simpara>Constructs a
        <computeroutput><classname>reference_wrapper</classname></computeroutput>
        object that stores a reference to
        <computeroutput>t</computeroutput>.</simpara></effects>

        <throws><simpara>Does not throw.</simpara></throws>
      </constructor>    

      <method-group name="access">
        <method name="conversion-operator" cv="const">
          <type>T&amp;</type>
          <returns><simpara>The stored reference.</simpara></returns>
          <throws><simpara>Does not throw.</simpara></throws>
        </method>

        <method name="get" cv="const">
          <type>T&amp;</type>
          <returns><simpara>The stored reference.</simpara></returns>
          <throws><simpara>Does not throw.</simpara></throws>
        </method>

        <method name="get_pointer" cv="const">
          <type>T*</type>
          <returns><simpara>A pointer to the object referenced by the stored reference.</simpara></returns>
          <throws><simpara>Does not throw.</simpara></throws>
        </method>
      </method-group>

      <free-function-group name="constructors">
        <function name="ref">
          <type>reference_wrapper&lt;T&gt;</type>
          <parameter name="t">
            <paramtype>T&amp;</paramtype>
          </parameter>

          <returns><simpara><computeroutput><classname>reference_wrapper</classname>&lt;T&gt;(t)</computeroutput></simpara></returns>

          <throws><simpara>Does not throw.</simpara></throws>
        </function>

        <function name="cref">
          <type>reference_wrapper&lt;T const&gt;</type>
          <parameter name="t">
            <paramtype>T const&amp;</paramtype>
          </parameter>

          <returns><simpara><computeroutput><classname>reference_wrapper</classname>&lt;T const&gt;(t)</computeroutput></simpara></returns>

          <throws><simpara>Does not throw.</simpara></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>

      <description>
        <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>
      </description>

      <static-constant name="value">
        <type>bool</type>
        <default><emphasis>unspecified</emphasis></default>
      </static-constant>
    </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>

      <description>
        <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>
      </description>

      <typedef name="type"><type><emphasis>unspecified</emphasis></type></typedef>
    </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&auml;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>