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/visitor_ptr.hpp">
11 <namespace name=
"boost">
13 <class name=
"visitor_ptr_t">
15 <template-type-parameter name=
"T"/>
16 <template-type-parameter name=
"R"/>
19 <purpose>Adapts a function pointer for use as a static visitor.
</purpose>
21 <simpara>Adapts the function given at construction for use as a
22 <link linkend=
"variant.concepts.static-visitor">static visitor
</link>
23 of type
<code>T
</code> with result type
<code>R
</code>.
</simpara>
26 <inherit access=
"public"><classname>static_visitor
</classname><R
></inherit>
28 <constructor specifiers=
"explicit">
30 <paramtype>R (*)(T)
</paramtype>
34 <simpara>Constructs the visitor with the given function.
</simpara>
38 <method-group name=
"static visitor interfaces">
39 <overloaded-method name=
"operator()">
43 <parameter name=
"operand">
44 <paramtype><emphasis>unspecified-forwarding-type
</emphasis></paramtype>
50 <template-type-parameter name=
"U"/>
56 <paramtype>const U
&</paramtype>
61 <simpara>If passed a value or reference of type
62 <code>T
</code>, it invokes the function given at
63 construction, appropriately forwarding
64 <code>operand
</code>.
</simpara>
66 <returns>Returns the result of the function invocation.
</returns>
68 <throws id=
"visitor_ptr_t.visit.throws">
69 <simpara>The overload taking a value or reference of type
70 <code>T
</code> throws if the invoked function throws.
71 The overload taking all other values
<emphasis>always
</emphasis>
72 throws
<code><classname>bad_visit
</classname></code>.
</simpara>
78 <function name=
"visitor_ptr">
80 <simpara>Returns a visitor object that adapts function pointers for
81 use as a static visitor.
</simpara>
84 <simpara>Constructs and returns a
85 <code><classname>visitor_ptr_t
</classname></code> adaptor over the
86 given function.
</simpara>
90 <template-type-parameter name=
"R"/>
91 <template-type-parameter name=
"T"/>
94 <type><classname>visitor_ptr_t
</classname><T,R
></type>
97 <paramtype>R (*)(T)
</paramtype>
101 <simpara>Returns a
<code><classname>visitor_ptr_t
</classname></code>
102 visitor object that, when applied, invokes the given
107 <simpara>Will not throw. (Note, however, that the returned
108 <classname alt=
"boost::visitor_ptr_t">visitor object
</classname> may
109 throw when applied.)
</simpara>