summaryrefslogtreecommitdiff
path: root/libs/variant/doc/reference/variant_fwd.xml
blob: 60765ca9b725774b151f6463c762be8fc556961a (plain)
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
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE header PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN"
  "http://www.boost.org/tools/boostbook/dtd/boostbook.dtd">
<!--
    Copyright 2003, Eric Friedman, Itay Maman.

    Distributed under the Boost Software License, Version 1.0. (See accompanying
    file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
-->
<header name="boost/variant/variant_fwd.hpp">
  <using-namespace name="boost"/>

  <para>Provides forward declarations of the
    <code><classname>boost::variant</classname></code>,
    <code><classname>boost::make_variant_over</classname></code>,
    <code><classname>boost::make_recursive_variant</classname></code>, and
    <code><classname>boost::make_recursive_variant_over</classname></code>
    class templates and the <code>boost::recursive_variant_</code> tag type.
    Also defines several preprocessor symbols, as described below.</para>

  <macro name="BOOST_VARIANT_LIMIT_TYPES">
    <purpose>
      <simpara>Expands to the length of the
        template parameter list for
        <code><classname>variant</classname></code>. Not used if
        <code><macroname>BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES</macroname></code>
        is not defined. 
      </simpara>
    </purpose>

    <description>
      <para><emphasis role="bold">Note</emphasis>: Conforming
        implementations of <code>variant</code> must allow at least ten
        template arguments. That is, BOOST_VARIANT_LIMIT_TYPES must be greater
        or equal to <code>10</code>.</para>
    </description>
  </macro>

  <macro name="BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES">
    <purpose>
      <simpara>If this macro is defined, then library won't use C++11 variadic templates.
        Users may define this macro to make 
        <code><macroname>BOOST_VARIANT_ENUM_PARAMS</macroname></code>
        and <code><macroname>BOOST_VARIANT_ENUM_SHIFTED_PARAMS</macroname></code> expand
        to a comma-separated sequence instead of variadic templates.
      </simpara>
    </purpose>
  </macro>

  <macro name="BOOST_VARIANT_ENUM_PARAMS" kind="functionlike">
    <macro-parameter name="param"/>

    <purpose>
      <simpara>Enumerate parameters for use with
        <code><classname>variant</classname></code>.</simpara>
    </purpose>

    <description>
      <para> When variadic templates are available and
        <code><macroname>BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES</macroname></code>
        is not defined, expands to variadic template list in the following manner:
        <code><programlisting>
            BOOST_VARIANT_ENUM_PARAMS(T)                    => T0, TN...
            BOOST_VARIANT_ENUM_PARAMS(class T)              => class T0, class... TN
            BOOST_VARIANT_ENUM_PARAMS(class Something)      => class Something0, class... SomethingN
            BOOST_VARIANT_ENUM_PARAMS(typename Something)   => typename Something0, typename... SomethingN
            BOOST_VARIANT_ENUM_PARAMS(Something)            => Something0, SomethingN...
            BOOST_VARIANT_ENUM_PARAMS(Something)            => Something0, SomethingN...
        </programlisting></code>
      </para>

      <para>
        Otherwise expands to a comma-separated sequence of length
        <code><macroname>BOOST_VARIANT_LIMIT_TYPES</macroname></code>, where
        each element in the sequence consists of the concatenation of
        <emphasis>param</emphasis> with its zero-based index into the
        sequence. That is,
        <code>param ## 0, param ## 1, ..., param ## BOOST_VARIANT_LIMIT_TYPES - 1</code>.</para>

      <para><emphasis role="bold">Rationale</emphasis>: This macro greatly
        simplifies for the user the process of declaring
        <code><classname>variant</classname></code> types
        in function templates or explicit partial specializations of class
        templates, as shown in the
        <link linkend="variant.tutorial.preprocessor">tutorial</link>.</para>
    </description>
  </macro>

  <macro name="BOOST_VARIANT_ENUM_SHIFTED_PARAMS" kind="functionlike">
    <macro-parameter name="param"/>

    <purpose>
      <simpara>Enumerate all but the first parameter for use with
        <code><classname>variant</classname></code>.</simpara>
    </purpose>

    <description>
      <para> When variadic templates are available and
        <code><macroname>BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES</macroname></code>
        is not defined, expands to variadic template list in the following manner:
        <code><programlisting>
            BOOST_VARIANT_ENUM_SHIFTED_PARAMS(T)                    => TN...
            BOOST_VARIANT_ENUM_SHIFTED_PARAMS(class T)              => class... TN
            BOOST_VARIANT_ENUM_SHIFTED_PARAMS(class Something)      => class... SomethingN
            BOOST_VARIANT_ENUM_SHIFTED_PARAMS(typename Something)   => typename... SomethingN
            BOOST_VARIANT_ENUM_SHIFTED_PARAMS(Something)            => SomethingN...
            BOOST_VARIANT_ENUM_SHIFTED_PARAMS(Something)            => SomethingN...
        </programlisting></code>
      </para>

      <para>
        Otherwise expands to a comma-separated sequence of length
        <code><macroname>BOOST_VARIANT_LIMIT_TYPES</macroname> - 1</code>,
        where each element in the sequence consists of the concatenation of
        <emphasis>param</emphasis> with its one-based index into the sequence.
        That is,
        <code>param ## 1, ..., param ## BOOST_VARIANT_LIMIT_TYPES - 1</code>.</para>

      <para><emphasis role="bold">Note</emphasis>: This macro results in the
        same expansion as
        <code><macroname>BOOST_VARIANT_ENUM_PARAMS</macroname></code> -- but
        without the first term.</para>
    </description>
  </macro>

  <macro name="BOOST_VARIANT_NO_REFERENCE_SUPPORT">
    <purpose>
      <simpara>Indicates <code><classname>variant</classname></code> does not
        support references as bounded types.</simpara>
    </purpose>

    <description>
      <para>Defined only if <code><classname>variant</classname></code> does
        not support references as bounded types.</para>
    </description>
  </macro>

  <macro name="BOOST_VARIANT_NO_TYPE_SEQUENCE_SUPPORT">
    <purpose>
      <simpara>Indicates absence of support for specifying the bounded types
        of a <code><classname>variant</classname></code> by the elements of a
        type sequence.</simpara>
    </purpose>

    <description>
      <para>Defined only if
        <code><classname>make_variant_over</classname></code> and
        <code><classname>make_recursive_variant_over</classname></code>
        are not supported for some reason on the target compiler.</para>
    </description>
  </macro>

  <macro name="BOOST_VARIANT_NO_FULL_RECURSIVE_VARIANT_SUPPORT">
    <purpose>
      <simpara>Indicates
        <code><classname>make_recursive_variant</classname></code> operates in
        an implementation-defined manner.</simpara>
    </purpose>

    <description>
      <para>Defined only if
        <code><classname>make_recursive_variant</classname></code> does not
        operate as documented on the target compiler, but rather in an
        implementation-defined manner.</para>

      <para><emphasis role="bold">Implementation Note</emphasis>: If
        <code>BOOST_VARIANT_NO_FULL_RECURSIVE_VARIANT_SUPPORT</code> is
        defined for the target compiler, the current implementation uses the
        <libraryname>MPL</libraryname> lambda mechanism to approximate the
        desired behavior. (In most cases, however, such compilers do not have
        full lambda support either.)</para>
    </description>
  </macro>
</header>