1 <!-- Copyright 2008 Lubomir Bourdev and Hailin Jin
3 Distributed under the Boost Software License, Version 1.0.
4 (See accompanying file LICENSE_1_0.txt or copy at
5 http://www.boost.org/LICENSE_1_0.txt)
9 Copyright 2005-2007 Adobe Systems Incorporated
10 Distributed under the MIT License (see accompanying file LICENSE_1_0_0.txt
11 or a copy at http://stlab.adobe.com/licenses.html)
13 Some files are held under additional license.
14 Please see "http://stlab.adobe.com/licenses.html" for more information.
17 <!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.0 Transitional//EN"
18 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
19 <html xmlns=
"http://www.w3.org/1999/xhtml" lang=
"en" xml:
lang=
"en">
22 <TITLE>Generic Image Library: variant Class Template Reference
</TITLE>
23 <META HTTP-EQUIV=
"content-type" CONTENT=
"text/html;charset=ISO-8859-1"/>
24 <LINK TYPE=
"text/css" REL=
"stylesheet" HREF=
"adobe_source.css"/>
27 <table border=
"0" cellspacing=
"0" cellpadding=
"0" style='width:
100%; margin:
0; padding:
0'
><tr>
28 <td width=
"100%" valign=
"top" style='padding-left:
10px; padding-right:
10px; padding-bottom:
10px'
>
29 <div class=
"qindex"><a class=
"qindex" href=
"index.html">Modules
</a>
30 |
<a class=
"qindex" href=
"classes.html">Alphabetical List
</a>
31 |
<a class=
"qindex" href=
"annotated.html">Class List
</a>
32 |
<a class=
"qindex" href=
"dirs.html">Directories
</a>
33 |
<a class=
"qindex" href=
"files.html">File List
</a>
34 |
<a class=
"qindex" href=
"../index.html">GIL Home Page
</a>
37 <!-- Generated by Doxygen 1.5.6 -->
38 <div class=
"navpath"><a class=
"el" href=
"namespaceboost.html">boost
</a>::
<b>gil
</b>::
<a class=
"el" href=
"g_i_l_0062.html">variant
</a>
40 <div class=
"contents">
41 <h1>variant Class Template Reference
<br>
43 [
<a class=
"el" href=
"group___variant.html">Variant
</a>]
</small>
44 </h1><!-- doxytag: class="boost::gil::variant" --><code>#include
<<a class=
"el" href=
"g_i_l_0643.html">variant.hpp
</a>></code>
48 <a href=
"g_i_l_0061.html">List of all members.
</a><hr><a name=
"_details"></a><h2>Detailed Description
</h2>
49 <h3>template
<typename Types
><br>
50 class boost::gil::variant
< Types
></h3>
52 Represents a concrete instance of a run-time specified type from a set of types
<p>
53 A concept is typically modeled by a collection of different types. They may be instantiations of a templated type with different template parameters or even completely unrelated types.
55 We call the type with which the concept is instantiated in a given place in the code
"the concrete type". The concrete type must be chosen at compile time, which sometimes is a severe limitation. Consider, for example, having an
<a class=
"el" href=
"g_i_l_0038.html" title=
"container interface over image view. Models ImageConcept, PixelBasedConcept">image
</a> concept modeled by an
<a class=
"el" href=
"g_i_l_0038.html" title=
"container interface over image view. Models ImageConcept, PixelBasedConcept">image
</a> class templated over the color space. It would be difficult to write a function that reads an
<a class=
"el" href=
"g_i_l_0038.html" title=
"container interface over image view. Models ImageConcept, PixelBasedConcept">image
</a> from file preserving its native color space, since the type of the return value is only available at run time. It would be difficult to store images of different color spaces in the same container or apply operations on them uniformly.
<p>
56 The
<a class=
"el" href=
"g_i_l_0062.html" title=
"Represents a concrete instance of a run-time specified type from a set of typesA...">variant
</a> class addresses this deficiency. It allows for run-time instantiation of a class from a given set of allowed classes specified at compile time. For example, the set of allowed classes may include
8-bit and
16-bit RGB and CMYK images. Such a
<a class=
"el" href=
"g_i_l_0062.html" title=
"Represents a concrete instance of a run-time specified type from a set of typesA...">variant
</a> can be constructed with rgb8_image_t and then assigned a cmyk16_image_t.
<p>
57 The
<a class=
"el" href=
"g_i_l_0062.html" title=
"Represents a concrete instance of a run-time specified type from a set of typesA...">variant
</a> has a templated constructor, which allows us to construct it with any concrete type instantiation. It can also perform a generic operation on the concrete type via a call to apply_operation. The operation must be provided as a function object whose application operator has a single parameter which can be instantiated with any of the allowed types of the
<a class=
"el" href=
"g_i_l_0062.html" title=
"Represents a concrete instance of a run-time specified type from a set of typesA...">variant
</a>.
<p>
58 <a class=
"el" href=
"g_i_l_0062.html" title=
"Represents a concrete instance of a run-time specified type from a set of typesA...">variant
</a> breaks down the instantiated type into a non-templated underlying base type and a unique instantiation type identifier. In the most common implementation the concrete instantiation in stored 'in-place' - in 'bits_t'. bits_t contains sufficient space to fit the largest of the instantiated objects.
<p>
59 GIL's
<a class=
"el" href=
"g_i_l_0062.html" title=
"Represents a concrete instance of a run-time specified type from a set of typesA...">variant
</a> is similar to boost::variant in spirit (hence we borrow the name from there) but it differs in several ways from the current
<a class=
"el" href=
"namespaceboost.html">boost
</a> implementation. Most notably, it does not take a variable number of template parameters but a single parameter defining the type enumeration. As such it can be used more effectively in generic code.
<p>
60 The Types parameter specifies the set of allowable types. It models MPL Random Access Container
<table border=
"0" cellpadding=
"0" cellspacing=
"0">
62 <tr><td colspan=
"2"><br><h2>Public Types
</h2></td></tr>
63 <tr><td class=
"memItemLeft" nowrap
align=
"right" valign=
"top"><a class=
"anchor" name=
"7134669ce8033ee155ef5fbd15d74d18"></a><!-- doxytag: member="boost::gil::variant::types_t" ref="7134669ce8033ee155ef5fbd15d74d18" args="" -->
64 typedef Types
</td><td class=
"memItemRight" valign=
"bottom"><b>types_t
</b></td></tr>
66 <tr><td colspan=
"2"><br><h2>Public Member Functions
</h2></td></tr>
67 <tr><td class=
"memTemplParams" nowrap
colspan=
"2"><a class=
"anchor" name=
"bb2707bdfa3fbe55028ff31812b8c070"></a><!-- doxytag: member="boost::gil::variant::variant" ref="bb2707bdfa3fbe55028ff31812b8c070" args="(const T &obj)" -->
68 template
<typename T
> </td></tr>
69 <tr><td class=
"memTemplItemLeft" nowrap
align=
"right" valign=
"top"> </td><td class=
"memTemplItemRight" valign=
"bottom"><b>variant
</b> (const T
&obj)
</td></tr>
71 <tr><td class=
"memTemplParams" nowrap
colspan=
"2"><a class=
"anchor" name=
"da037b594ec15101938c88fc698d80b7"></a><!-- doxytag: member="boost::gil::variant::variant" ref="da037b594ec15101938c88fc698d80b7" args="(T &obj, bool do_swap)" -->
72 template
<typename T
> </td></tr>
73 <tr><td class=
"memTemplItemLeft" nowrap
align=
"right" valign=
"top"> </td><td class=
"memTemplItemRight" valign=
"bottom"><b>variant
</b> (T
&obj, bool do_swap)
</td></tr>
75 <tr><td class=
"memTemplParams" nowrap
colspan=
"2"><a class=
"anchor" name=
"3ae126b388a09f750c4fc2d2761600a7"></a><!-- doxytag: member="boost::gil::variant::operator=" ref="3ae126b388a09f750c4fc2d2761600a7" args="(const T &obj)" -->
76 template
<typename T
> </td></tr>
77 <tr><td class=
"memTemplItemLeft" nowrap
align=
"right" valign=
"top"><a class=
"el" href=
"g_i_l_0062.html">variant
</a> & </td><td class=
"memTemplItemRight" valign=
"bottom"><b>operator=
</b> (const T
&obj)
</td></tr>
79 <tr><td class=
"memItemLeft" nowrap
align=
"right" valign=
"top"><a class=
"anchor" name=
"dd6b734e8571d58bf212f9ee6e6251ab"></a><!-- doxytag: member="boost::gil::variant::operator=" ref="dd6b734e8571d58bf212f9ee6e6251ab" args="(const variant &v)" -->
80 <a class=
"el" href=
"g_i_l_0062.html">variant
</a> & </td><td class=
"memItemRight" valign=
"bottom"><b>operator=
</b> (const
<a class=
"el" href=
"g_i_l_0062.html">variant
</a> &v)
</td></tr>
82 <tr><td class=
"memItemLeft" nowrap
align=
"right" valign=
"top"><a class=
"anchor" name=
"d17d9c5c9f034b9a545a0e0b40a29049"></a><!-- doxytag: member="boost::gil::variant::variant" ref="d17d9c5c9f034b9a545a0e0b40a29049" args="(const variant &v)" -->
83 </td><td class=
"memItemRight" valign=
"bottom"><b>variant
</b> (const
<a class=
"el" href=
"g_i_l_0062.html">variant
</a> &v)
</td></tr>
85 <tr><td class=
"memTemplParams" nowrap
colspan=
"2"><a class=
"anchor" name=
"e003bd0bc96ce08b883dbf864a48b450"></a><!-- doxytag: member="boost::gil::variant::move_in" ref="e003bd0bc96ce08b883dbf864a48b450" args="(T &obj)" -->
86 template
<typename T
> </td></tr>
87 <tr><td class=
"memTemplItemLeft" nowrap
align=
"right" valign=
"top">void
</td><td class=
"memTemplItemRight" valign=
"bottom"><b>move_in
</b> (T
&obj)
</td></tr>
89 <tr><td class=
"memTemplParams" nowrap
colspan=
"2"><a class=
"anchor" name=
"34ea494472846acdd760285d85d7dc22"></a><!-- doxytag: member="boost::gil::variant::_dynamic_cast" ref="34ea494472846acdd760285d85d7dc22" args="() const " -->
90 template
<typename T
> </td></tr>
91 <tr><td class=
"memTemplItemLeft" nowrap
align=
"right" valign=
"top">const T
& </td><td class=
"memTemplItemRight" valign=
"bottom"><b>_dynamic_cast
</b> () const
</td></tr>
93 <tr><td class=
"memTemplParams" nowrap
colspan=
"2"><a class=
"anchor" name=
"7c84cd1f68db5e601c4721a8a2c5ba6f"></a><!-- doxytag: member="boost::gil::variant::_dynamic_cast" ref="7c84cd1f68db5e601c4721a8a2c5ba6f" args="()" -->
94 template
<typename T
> </td></tr>
95 <tr><td class=
"memTemplItemLeft" nowrap
align=
"right" valign=
"top">T
& </td><td class=
"memTemplItemRight" valign=
"bottom"><b>_dynamic_cast
</b> ()
</td></tr>
97 <tr><td class=
"memTemplParams" nowrap
colspan=
"2"><a class=
"anchor" name=
"6457b76cdd59d781e0ee841286806b1a"></a><!-- doxytag: member="boost::gil::variant::current_type_is" ref="6457b76cdd59d781e0ee841286806b1a" args="() const " -->
98 template
<typename T
> </td></tr>
99 <tr><td class=
"memTemplItemLeft" nowrap
align=
"right" valign=
"top">bool
</td><td class=
"memTemplItemRight" valign=
"bottom"><b>current_type_is
</b> () const
</td></tr>
101 <tr><td colspan=
"2"><br><h2>Static Public Member Functions
</h2></td></tr>
102 <tr><td class=
"memTemplParams" nowrap
colspan=
"2"><a class=
"anchor" name=
"36f726b4e4a28a717b3a923895578559"></a><!-- doxytag: member="boost::gil::variant::has_type" ref="36f726b4e4a28a717b3a923895578559" args="()" -->
103 template
<typename T
> </td></tr>
104 <tr><td class=
"memTemplItemLeft" nowrap
align=
"right" valign=
"top">static bool
</td><td class=
"memTemplItemRight" valign=
"bottom"><b>has_type
</b> ()
</td></tr>
106 <tr><td colspan=
"2"><br><h2>Friends
</h2></td></tr>
107 <tr><td class=
"memTemplParams" nowrap
colspan=
"2"><a class=
"anchor" name=
"8ddc806c49b5ebc278ed1df04659363c"></a><!-- doxytag: member="boost::gil::variant::operator==" ref="8ddc806c49b5ebc278ed1df04659363c" args="(const variant< TS > &x, const variant< TS > &y)" -->
108 template
<typename TS
> </td></tr>
109 <tr><td class=
"memTemplItemLeft" nowrap
align=
"right" valign=
"top">bool
</td><td class=
"memTemplItemRight" valign=
"bottom"><b>operator==
</b> (const
<a class=
"el" href=
"g_i_l_0062.html">variant
</a>< TS
> &x, const
<a class=
"el" href=
"g_i_l_0062.html">variant
</a>< TS
> &y)
</td></tr>
111 <tr><td class=
"memTemplParams" nowrap
colspan=
"2"><a class=
"anchor" name=
"dc042a6804c230a421fa276fa28a3288"></a><!-- doxytag: member="boost::gil::variant::operator!=" ref="dc042a6804c230a421fa276fa28a3288" args="(const variant< TS > &x, const variant< TS > &y)" -->
112 template
<typename TS
> </td></tr>
113 <tr><td class=
"memTemplItemLeft" nowrap
align=
"right" valign=
"top">bool
</td><td class=
"memTemplItemRight" valign=
"bottom"><b>operator!=
</b> (const
<a class=
"el" href=
"g_i_l_0062.html">variant
</a>< TS
> &x, const
<a class=
"el" href=
"g_i_l_0062.html">variant
</a>< TS
> &y)
</td></tr>
115 <tr><td class=
"memTemplParams" nowrap
colspan=
"2"><a class=
"anchor" name=
"7657b84c44bec27d2775a546982dd27d"></a><!-- doxytag: member="boost::gil::variant::swap" ref="7657b84c44bec27d2775a546982dd27d" args="(variant< Cs > &x, variant< Cs > &y)" -->
116 template
<typename Cs
> </td></tr>
117 <tr><td class=
"memTemplItemLeft" nowrap
align=
"right" valign=
"top">void
</td><td class=
"memTemplItemRight" valign=
"bottom"><b>swap
</b> (
<a class=
"el" href=
"g_i_l_0062.html">variant
</a>< Cs
> &x,
<a class=
"el" href=
"g_i_l_0062.html">variant
</a>< Cs
> &y)
</td></tr>
119 <tr><td class=
"memTemplParams" nowrap
colspan=
"2"><a class=
"anchor" name=
"5a2b09b34d730defa678a0577e2e044b"></a><!-- doxytag: member="boost::gil::variant::apply_operation" ref="5a2b09b34d730defa678a0577e2e044b" args="(variant< Types2 > &var, UnaryOp op)" -->
120 template
<typename Types2, typename UnaryOp
> </td></tr>
121 <tr><td class=
"memTemplItemLeft" nowrap
align=
"right" valign=
"top">UnaryOp::result_type
</td><td class=
"memTemplItemRight" valign=
"bottom"><b>apply_operation
</b> (
<a class=
"el" href=
"g_i_l_0062.html">variant
</a>< Types2
> &var, UnaryOp op)
</td></tr>
123 <tr><td class=
"memTemplParams" nowrap
colspan=
"2"><a class=
"anchor" name=
"78ada22248f20734361616cefbc6ef5c"></a><!-- doxytag: member="boost::gil::variant::apply_operation" ref="78ada22248f20734361616cefbc6ef5c" args="(const variant< Types2 > &var, UnaryOp op)" -->
124 template
<typename Types2, typename UnaryOp
> </td></tr>
125 <tr><td class=
"memTemplItemLeft" nowrap
align=
"right" valign=
"top">UnaryOp::result_type
</td><td class=
"memTemplItemRight" valign=
"bottom"><b>apply_operation
</b> (const
<a class=
"el" href=
"g_i_l_0062.html">variant
</a>< Types2
> &var, UnaryOp op)
</td></tr>
127 <tr><td class=
"memTemplParams" nowrap
colspan=
"2"><a class=
"anchor" name=
"780f3b531376ac914d9b016631e2b081"></a><!-- doxytag: member="boost::gil::variant::apply_operation" ref="780f3b531376ac914d9b016631e2b081" args="(const variant< Types1 > &arg1, const variant< Types2 > &arg2, BinaryOp op)" -->
128 template
<typename Types1, typename Types2, typename BinaryOp
> </td></tr>
129 <tr><td class=
"memTemplItemLeft" nowrap
align=
"right" valign=
"top">BinaryOp::result_type
</td><td class=
"memTemplItemRight" valign=
"bottom"><a class=
"el" href=
"g_i_l_0062.html#780f3b531376ac914d9b016631e2b081">apply_operation
</a> (const
<a class=
"el" href=
"g_i_l_0062.html">variant
</a>< Types1
> &arg1, const
<a class=
"el" href=
"g_i_l_0062.html">variant
</a>< Types2
> &arg2, BinaryOp op)
</td></tr>
131 <tr><td class=
"mdescLeft"> </td><td class=
"mdescRight">Invokes a generic constant operation (represented as a binary function object) on two variants.
<br></td></tr>
133 <hr>The documentation for this class was generated from the following file:
<ul>
134 <li><a class=
"el" href=
"g_i_l_0643.html">variant.hpp
</a></ul>
136 <hr size=
"1"><address style=
"text-align: right;"><small>Generated on Sat May
2 13:
50:
18 2009 for Generic Image Library by
137 <a href=
"http://www.doxygen.org/index.html">
138 <img src=
"doxygen.png" alt=
"doxygen" align=
"middle" border=
"0"></a> 1.5.6 </small></address>