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
|
<?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">
<header name="boost/variant/apply_visitor.hpp">
<namespace name="boost">
<class name="apply_visitor_delayed_t">
<purpose>Adapts a visitor for use as a function object.</purpose>
<description>
<simpara>Adapts the function given at construction for use as a
function object. This is useful, for example, when one needs to
operate on each element of a sequence of variant objects using a
standard library algorithm such as
<code>std::for_each</code>.</simpara>
<simpara>See the "visitor-only" form of
<code><functionname>apply_visitor</functionname></code> for a simple
way to create <code>apply_visitor_delayed_t</code> objects.</simpara>
</description>
<template>
<template-type-parameter name="Visitor"/>
</template>
<typedef name="result_type">
<type>typename Visitor::result_type</type>
</typedef>
<constructor specifiers="explicit">
<parameter name="visitor">
<paramtype>Visitor &</paramtype>
</parameter>
<effects>
<simpara>Constructs the function object with the given
visitor.</simpara>
</effects>
</constructor>
<method-group name="function object interface">
<overloaded-method name="operator()">
<signature>
<template>
<template-type-parameter name="Variant"/>
</template>
<type>result_type</type>
<parameter name="operand">
<paramtype>Variant &</paramtype>
</parameter>
</signature>
<signature>
<template>
<template-type-parameter name="Variant1"/>
<template-type-parameter name="Variant2"/>
</template>
<type>result_type</type>
<parameter name="operand1">
<paramtype>Variant1 &</paramtype>
</parameter>
<parameter name="operand2">
<paramtype>Variant2 &</paramtype>
</parameter>
</signature>
<purpose>Function call operator.</purpose>
<description>
<simpara>Invokes
<code><functionname>apply_visitor</functionname></code> on the
stored visitor using the given operands.</simpara>
</description>
</overloaded-method>
</method-group>
</class>
<overloaded-function name="apply_visitor">
<signature>
<template>
<template-type-parameter name="Visitor"/>
<template-type-parameter name="Variant"/>
</template>
<type>typename Visitor::result_type</type>
<parameter name="visitor">
<paramtype>Visitor &</paramtype>
</parameter>
<parameter name="operand">
<paramtype>Variant &</paramtype>
</parameter>
</signature>
<signature>
<template>
<template-type-parameter name="Visitor"/>
<template-type-parameter name="Variant"/>
</template>
<type>typename Visitor::result_type</type>
<parameter name="visitor">
<paramtype>const Visitor &</paramtype>
</parameter>
<parameter name="operand">
<paramtype>Variant &</paramtype>
</parameter>
</signature>
<signature>
<template>
<template-type-parameter name="BinaryVisitor"/>
<template-type-parameter name="Variant1"/>
<template-type-parameter name="Variant2"/>
</template>
<type>typename BinaryVisitor::result_type</type>
<parameter name="visitor">
<paramtype>BinaryVisitor &</paramtype>
</parameter>
<parameter name="operand1">
<paramtype>Variant1 &</paramtype>
</parameter>
<parameter name="operand2">
<paramtype>Variant2 &</paramtype>
</parameter>
</signature>
<signature>
<template>
<template-type-parameter name="BinaryVisitor"/>
<template-type-parameter name="Variant1"/>
<template-type-parameter name="Variant2"/>
</template>
<type>typename BinaryVisitor::result_type</type>
<parameter name="visitor">
<paramtype>const BinaryVisitor &</paramtype>
</parameter>
<parameter name="operand1">
<paramtype>Variant1 &</paramtype>
</parameter>
<parameter name="operand2">
<paramtype>Variant2 &</paramtype>
</parameter>
</signature>
<signature>
<template>
<template-type-parameter name="Visitor"/>
</template>
<type><classname>apply_visitor_delayed_t</classname><Visitor></type>
<parameter name="visitor">
<paramtype>Visitor &</paramtype>
</parameter>
</signature>
<purpose>
<simpara>Allows compile-time checked type-safe application of the
given visitor to the content of the given variant, ensuring that all
types are handled by the visitor.</simpara>
</purpose>
<description>
<simpara>The behavior of <code>apply_visitor</code> is dependent on
the number of arguments on which it operates (i.e., other than the
visitor). The function behaves as follows:
<itemizedlist>
<listitem>Overloads accepting one operand invoke the unary function
call operator of the given visitor on the content of the given
<code><classname>variant</classname></code> operand.</listitem>
<listitem>Overloads accepting two operands invoke the binary
function call operator of the given visitor on the content of
the given <code><classname>variant</classname></code>
operands.</listitem>
<listitem>The overload accepting only a visitor returns a
<classname alt="boost::apply_visitor_delayed_t">generic function object</classname>
that accepts either one or two arguments and invokes
<code><functionname>apply_visitor</functionname></code> using
these arguments and <code>visitor</code>, thus behaving as
specified above. (This behavior is particularly useful, for
example, when one needs to operate on each element of a sequence
of variant objects using a standard library
algorithm.)</listitem>
</itemizedlist>
</simpara>
</description>
<returns>
<simpara>The overloads acccepting operands return the result of
applying the given visitor to the content of the given operands.
The overload accepting only a visitor return a function object, thus
delaying application of the visitor to any operands.</simpara>
</returns>
<requires>
<simpara>The given visitor must fulfill the
<link linkend="variant.concepts.static-visitor"><emphasis>StaticVisitor</emphasis></link>
concept requirements with respect to each of the bounded types of the
given <code>variant</code>.</simpara>
</requires>
<throws>
<simpara>The overloads accepting operands throw only if the given
visitor throws when applied. The overload accepting only a visitor
will not throw. (Note, however, that the returned
<classname alt="boost::apply_visitor_delayed_t">function object</classname>
may throw when invoked.)</simpara>
</throws>
</overloaded-function>
</namespace>
</header>
|