1 | <html> |
---|
2 | <head> |
---|
3 | <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> |
---|
4 | <title>Function apply_visitor</title> |
---|
5 | <link rel="stylesheet" href="boostbook.css" type="text/css"> |
---|
6 | <meta name="generator" content="DocBook XSL Stylesheets V1.69.1"> |
---|
7 | <link rel="start" href="index.html" title="The Boost C++ Libraries"> |
---|
8 | <link rel="up" href="variant/reference.html#id2660594" title="Header <boost/variant/apply_visitor.hpp>"> |
---|
9 | <link rel="prev" href="apply_visitor_delayed_t.html" title="Class template apply_visitor_delayed_t"> |
---|
10 | <link rel="next" href="bad_get.html" title="Class bad_get"> |
---|
11 | </head> |
---|
12 | <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> |
---|
13 | <table cellpadding="2" width="100%"> |
---|
14 | <td valign="top"><img alt="boost.png (6897 bytes)" width="277" height="86" src="../../boost.png"></td> |
---|
15 | <td align="center"><a href="../../index.htm">Home</a></td> |
---|
16 | <td align="center"><a href="../../libs/libraries.htm">Libraries</a></td> |
---|
17 | <td align="center"><a href="../../people/people.htm">People</a></td> |
---|
18 | <td align="center"><a href="../../more/faq.htm">FAQ</a></td> |
---|
19 | <td align="center"><a href="../../more/index.htm">More</a></td> |
---|
20 | </table> |
---|
21 | <hr> |
---|
22 | <div class="spirit-nav"> |
---|
23 | <a accesskey="p" href="apply_visitor_delayed_t.html"><img src="images/prev.png" alt="Prev"></a><a accesskey="u" href="variant/reference.html#id2660594"><img src="images/up.png" alt="Up"></a><a accesskey="h" href="index.html"><img src="images/home.png" alt="Home"></a><a accesskey="n" href="bad_get.html"><img src="images/next.png" alt="Next"></a> |
---|
24 | </div> |
---|
25 | <div class="refentry" lang="en"> |
---|
26 | <a name="apply_visitor"></a><div class="titlepage"></div> |
---|
27 | <div class="refnamediv"> |
---|
28 | <h2><span class="refentrytitle">Function apply_visitor</span></h2> |
---|
29 | <p>boost::apply_visitor — <p>Allows compile-time checked type-safe application of the |
---|
30 | given visitor to the content of the given variant, ensuring that all |
---|
31 | types are handled by the visitor.</p></p> |
---|
32 | </div> |
---|
33 | <h2 xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv-title">Synopsis</h2> |
---|
34 | <div xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv"><pre class="synopsis"> |
---|
35 | <span class="bold"><strong>template</strong></span><<span class="bold"><strong>typename</strong></span> Visitor, <span class="bold"><strong>typename</strong></span> Variant> |
---|
36 | <span class="type"><span class="bold"><strong>typename</strong></span> Visitor::result_type</span> |
---|
37 | apply_visitor(Visitor & visitor, Variant & operand); |
---|
38 | <span class="bold"><strong>template</strong></span><<span class="bold"><strong>typename</strong></span> Visitor, <span class="bold"><strong>typename</strong></span> Variant> |
---|
39 | <span class="type"><span class="bold"><strong>typename</strong></span> Visitor::result_type</span> |
---|
40 | apply_visitor(<span class="bold"><strong>const</strong></span> Visitor & visitor, Variant & operand); |
---|
41 | <span class="bold"><strong>template</strong></span><<span class="bold"><strong>typename</strong></span> BinaryVisitor, <span class="bold"><strong>typename</strong></span> Variant1, <span class="bold"><strong>typename</strong></span> Variant2> |
---|
42 | <span class="type"><span class="bold"><strong>typename</strong></span> BinaryVisitor::result_type</span> |
---|
43 | apply_visitor(BinaryVisitor & visitor, Variant1 & operand1, |
---|
44 | Variant2 & operand2); |
---|
45 | <span class="bold"><strong>template</strong></span><<span class="bold"><strong>typename</strong></span> BinaryVisitor, <span class="bold"><strong>typename</strong></span> Variant1, <span class="bold"><strong>typename</strong></span> Variant2> |
---|
46 | <span class="type"><span class="bold"><strong>typename</strong></span> BinaryVisitor::result_type</span> |
---|
47 | apply_visitor(<span class="bold"><strong>const</strong></span> BinaryVisitor & visitor, Variant1 & operand1, |
---|
48 | Variant2 & operand2); |
---|
49 | <span class="bold"><strong>template</strong></span><<span class="bold"><strong>typename</strong></span> Visitor> |
---|
50 | <span class="type"><a href="apply_visitor_delayed_t.html" title="Class template apply_visitor_delayed_t">apply_visitor_delayed_t</a><Visitor></span> apply_visitor(Visitor & visitor);</pre></div> |
---|
51 | <div class="refsect1" lang="en"> |
---|
52 | <a name="id2838602"></a><h2>Description</h2> |
---|
53 | <p>The behavior of <code class="computeroutput">apply_visitor</code> is dependent on |
---|
54 | the number of arguments on which it operates (i.e., other than the |
---|
55 | visitor). The function behaves as follows: |
---|
56 | |
---|
57 | <div class="itemizedlist"><ul type="disc"> |
---|
58 | <li>Overloads accepting one operand invoke the unary function |
---|
59 | call operator of the given visitor on the content of the given |
---|
60 | <code class="computeroutput"><a href="boost/variant.html" title="Class template variant">variant</a></code> operand.</li> |
---|
61 | <li>Overloads accepting two operands invoke the binary |
---|
62 | function call operator of the given visitor on the content of |
---|
63 | the given <code class="computeroutput"><a href="boost/variant.html" title="Class template variant">variant</a></code> |
---|
64 | operands.</li> |
---|
65 | <li>The overload accepting only a visitor returns a |
---|
66 | <code class="computeroutput"><a href="apply_visitor_delayed_t.html" title="Class template apply_visitor_delayed_t">generic function object</a></code> |
---|
67 | that accepts either one or two arguments and invokes |
---|
68 | <code class="computeroutput"><a href="apply_visitor.html" title="Function apply_visitor">apply_visitor</a></code> using |
---|
69 | these arguments and <code class="computeroutput">visitor</code>, thus behaving as |
---|
70 | specified above. (This behavior is particularly useful, for |
---|
71 | example, when one needs to operate on each element of a sequence |
---|
72 | of variant objects using a standard library |
---|
73 | algorithm.)</li> |
---|
74 | </ul></div></p> |
---|
75 | <p><b xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision"><span class="term">Returns</span></b>: |
---|
76 | |
---|
77 | The overloads acccepting operands return the result of |
---|
78 | applying the given visitor to the content of the given operands. |
---|
79 | The overload accepting only a visitor return a function object, thus |
---|
80 | delaying application of the visitor to any operands.<br><b xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision"><span class="term">Requires</span></b>: |
---|
81 | |
---|
82 | The given visitor must fulfill the |
---|
83 | <a href="variant/reference.html#variant.concepts.static-visitor" title="StaticVisitor"><span class="emphasis"><em>StaticVisitor</em></span></a> |
---|
84 | concept requirements with respect to each of the bounded types of the |
---|
85 | given <code class="computeroutput">variant</code>.<br><b xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision"><span class="term">Throws</span></b>: |
---|
86 | |
---|
87 | The overloads accepting operands throw only if the given |
---|
88 | visitor throws when applied. The overload accepting only a visitor |
---|
89 | will not throw. (Note, however, that the returned |
---|
90 | <a href="apply_visitor_delayed_t.html" title="Class template apply_visitor_delayed_t">function object</a> |
---|
91 | may throw when invoked.)</p> |
---|
92 | </div> |
---|
93 | </div> |
---|
94 | <table width="100%"><tr> |
---|
95 | <td align="left"></td> |
---|
96 | <td align="right"><small>Copyright © 2002, 2003 Eric Friedman, Itay Maman</small></td> |
---|
97 | </tr></table> |
---|
98 | <hr> |
---|
99 | <div class="spirit-nav"> |
---|
100 | <a accesskey="p" href="apply_visitor_delayed_t.html"><img src="images/prev.png" alt="Prev"></a><a accesskey="u" href="variant/reference.html#id2660594"><img src="images/up.png" alt="Up"></a><a accesskey="h" href="index.html"><img src="images/home.png" alt="Home"></a><a accesskey="n" href="bad_get.html"><img src="images/next.png" alt="Next"></a> |
---|
101 | </div> |
---|
102 | </body> |
---|
103 | </html> |
---|