1 <?xml version=
"1.0" encoding=
"utf-8"?>
2 <!DOCTYPE header PUBLIC
"-//Boost//DTD BoostBook XML V1.0//EN"
3 "http://www.boost.org/tools/boostbook/dtd/boostbook.dtd">
5 Copyright 2003, Eric Friedman, Itay Maman.
7 Distributed under the Boost Software License, Version 1.0. (See accompanying
8 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
10 <header name=
"boost/variant/recursive_wrapper.hpp">
11 <namespace name=
"boost">
13 <class name=
"recursive_wrapper">
14 <purpose>Solves circular dependencies, enabling recursive types.
</purpose>
17 <template-type-parameter name=
"T"/>
21 <simpara>The
<code>recursive_wrapper
</code> class template has an
22 interface similar to a simple value container, but its content is
23 allocated dynamically. This allows
<code>recursive_wrapper
</code> to
24 hold types
<code>T
</code> whose member data leads to a circular
25 dependency (e.g., a data member of
<code>T
</code> has a data member
26 of type
<code>T
</code>).
</simpara>
28 <simpara>The application of
<code>recursive_wrapper
</code> is easiest
29 understood in context. See
30 <xref linkend=
"variant.tutorial.recursive.recursive-wrapper"/> for a
31 demonstration of a common use of the class template.
</simpara>
33 <simpara><emphasis role=
"bold">Notes
</emphasis>:
</simpara>
35 <listitem>Any type specified as the template argument to
36 <code>recursive_wrapper
</code> must be capable of construction via
37 <code>operator new
</code>. Thus, for instance, references are not
47 <purpose>Destructor.
</purpose>
49 <simpara>Deletes the content of
<code>*this
</code>.
</simpara>
52 <throws>Will not throw.
</throws>
56 <purpose>Default constructor.
</purpose>
58 <simpara>Initializes
<code>*this
</code> by default construction of
59 <code>T
</code>.
</simpara>
63 <simpara><code>T
</code> must fulfill the requirements of the
64 <emphasis>DefaultConstructible
</emphasis> [
20.1.4]
69 <simpara>May fail with any exceptions arising from the default
70 constructor of
<code>T
</code> or, in the event of
71 insufficient memory, with
<code>std::bad_alloc
</code>.
</simpara>
76 <parameter name=
"other">
77 <paramtype>const recursive_wrapper
&</paramtype>
80 <purpose>Copy constructor.
</purpose>
82 <simpara>Copies the content of
<code>other
</code> into
83 <code>*this
</code>.
</simpara>
87 <simpara>May fail with any exceptions arising from the
88 copy constructor of
<code>T
</code> or, in the event of
89 insufficient memory, with
<code>std::bad_alloc
</code>.
</simpara>
94 <parameter name=
"operand">
95 <paramtype>const T
&</paramtype>
98 <purpose>Value constructor.
</purpose>
100 <simpara>Copies
<code>operand
</code> into
101 <code>*this
</code>.
</simpara>
105 <simpara>May fail with any exceptions arising from the
106 copy constructor of
<code>T
</code> or, in the event of
107 insufficient memory, with
<code>std::bad_alloc
</code>.
</simpara>
111 <method-group name=
"modifiers">
116 <parameter name=
"other">
117 <paramtype>recursive_wrapper
&</paramtype>
121 <simpara>Exchanges contents of
<code>*this
</code> and
122 <code>other
</code>.
</simpara>
125 <throws>Will not throw.
</throws>
128 <method name=
"operator=">
129 <type>recursive_wrapper
&</type>
131 <parameter name=
"rhs">
132 <paramtype>const recursive_wrapper
&</paramtype>
135 <purpose>Copy assignment operator.
</purpose>
137 <simpara>Assigns the content of
<code>rhs
</code> to the content of
138 <code>*this
</code>.
</simpara>
142 <simpara><code>T
</code> must fulfill the requirements of
143 the
<conceptname>Assignable
</conceptname>
148 <simpara>May fail with any exceptions arising from the assignment
149 operator of
<code>T
</code>.
</simpara>
153 <method name=
"operator=">
154 <type>recursive_wrapper
&</type>
156 <parameter name=
"rhs">
157 <paramtype>const T
&</paramtype>
160 <purpose>Value assignment operator.
</purpose>
162 <simpara>Assigns
<code>rhs
</code> into the content of
163 <code>*this
</code>.
</simpara>
167 <simpara><code>T
</code> must fulfill the requirements of the
168 <conceptname>Assignable
</conceptname>
173 <simpara>May fail with any exceptions arising from the assignment
174 operator of
<code>T
</code>.
</simpara>
180 <method-group name=
"queries">
182 <overloaded-method name=
"get">
186 <signature cv=
"const">
187 <type>const T
&</type>
191 <simpara>Returns a reference to the content of
192 <code>*this
</code>.
</simpara>
195 <throws>Will not throw.
</throws>
198 <overloaded-method name=
"get_pointer">
202 <signature cv=
"const">
203 <type>const T *
</type>
207 <simpara>Returns a pointer to the content of
208 <code>*this
</code>.
</simpara>
211 <throws>Will not throw.
</throws>
218 <class name=
"is_recursive_wrapper">
220 <simpara>Determines whether the specified type is a specialization of
221 <code>recursive_wrapper
</code>.
</simpara>
225 <template-type-parameter name=
"T"/>
229 <simpara>Value is true iff
<code>T
</code> is a specialization of
230 <code><classname>recursive_wrapper
</classname></code>.
</simpara>
231 <simpara><emphasis role=
"bold">Note
</emphasis>:
232 <code>is_recursive_wrapper
</code> is a model of
233 <libraryname>MPL
</libraryname>'s
234 <emphasis>IntegralConstant
</emphasis> concept.
</simpara>
237 <typedef name=
"type">
238 <type><emphasis>unspecified
</emphasis></type>
241 <static-constant name=
"value">
243 <default><emphasis>unspecified
</emphasis></default>
247 <class name=
"unwrap_recursive_wrapper">
249 <simpara>Unwraps the specified argument if given a specialization of
250 <code><classname>recursive_wrapper
</classname></code>.
</simpara>
254 <template-type-parameter name=
"T"/>
258 <simpara><code>type
</code> is equivalent to
<code>T::type
</code> if
259 <code>T
</code> is a specialization of
260 <code><classname>recursive_wrapper
</classname></code>. Otherwise,
261 <code>type
</code> is equivalent to
<code>T
</code>.
</simpara>
264 <typedef name=
"type">
265 <type><emphasis>unspecified
</emphasis></type>