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 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379
|
<?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.
Copyright 2013-2023 Antony Polukhin.
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/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>
<simpara>See <code><classname>apply_visitor_delayed_cpp14_t</classname></code>
which is used on C++14 compatible compilers when <code>Visitor</code> has no
<code>result_type</code> typedef.</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="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>
<notes>Version with variadic templates is used by default if
<macroname>BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES</macroname> is not defined.</notes>
</overloaded-method>
</method-group>
</class>
<class name="apply_visitor_delayed_cpp14_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>
<simpara>See <code><classname>apply_visitor_delayed_t</classname></code>
which is used when <code>Visitor</code> has <code>result_type</code>
typedef.</simpara>
<simpara>Available only if macro
<macroname>BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES</macroname> is not defined and
compiler supports <code>decltype(auto)</code> and <code>decltype(some-expression)</code>.</simpara>
</description>
<template>
<template-type-parameter name="Visitor"/>
</template>
<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>decltype(auto)</type>
<parameter name="operand">
<paramtype>Variant&...</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 OR decltype(auto)</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 OR decltype(auto)</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="MultiVisitor"/>
<template-type-parameter name="Variant1"/>
<template-type-parameter name="Variant2"/>
<template-type-parameter name="Variant3"/>
</template>
<type>typename MultiVisitor::result_type OR decltype(auto)</type>
<parameter name="visitor">
<paramtype>MultiVisitor &</paramtype>
</parameter>
<parameter name="operand1">
<paramtype>Variant1&&</paramtype>
</parameter>
<parameter name="operand2">
<paramtype>Variant2&&</paramtype>
</parameter>
<parameter name="operand3">
<paramtype>Variant3&&</paramtype>
</parameter>
<parameter name="other_operands">
<paramtype>...</paramtype>
</parameter>
</signature>
<signature>
<template>
<template-type-parameter name="MultiVisitor"/>
<template-type-parameter name="Variant1"/>
<template-type-parameter name="Variant2"/>
<template-type-parameter name="Variant3"/>
</template>
<type>typename MultiVisitor::result_type OR decltype(auto)</type>
<parameter name="visitor">
<paramtype>const MultiVisitor &</paramtype>
</parameter>
<parameter name="operand1">
<paramtype>Variant1&&</paramtype>
</parameter>
<parameter name="operand2">
<paramtype>Variant2&&</paramtype>
</parameter>
<parameter name="operand3">
<paramtype>Variant3&&</paramtype>
</parameter>
<parameter name="other_operands">
<paramtype>...</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>
<signature>
<template>
<template-type-parameter name="Visitor"/>
</template>
<type><classname>apply_visitor_delayed_cpp14_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). If your compiler does not support the rvalue references or reference qualifiers then all the
forwarding references from above degrade to non const lvalue reference. 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>Overloads accepting three or more operands invoke the
function call operator of the given visitor on the content of
the given <code><classname>variant</classname></code>
operands. Maximum amount of parameters controlled by
<code><emphasis role="bold"><macroname>BOOST_VARAINT_MAX_MULTIVIZITOR_PARAMS</macroname></emphasis></code>
macro. Those functions are actually defined in a header <code>boost/variant/multivisitors.hpp</code>
(See <xref linkend="header.boost.variant.multivisitors_hpp"/>). That header must be manually included
if multi visitors are meant for use.</listitem>
<listitem>The overloads accepting only a visitor return a
<classname alt="boost::apply_visitor_delayed_t">C++03 compatible generic function object</classname>
or
<classname alt="boost::apply_visitor_delayed_cpp14_t">C++14 compatible generic function object</classname>
that accepts either one, two or arbitrary count of arguments and invoke
<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>
|