[ VIGRA Homepage | Function Index | Class Index | Namespaces | File List | Main Page ]

tuple.hxx |

1 /************************************************************************/
2 /* */
3 /* Copyright 1998-2002 by Ullrich Koethe */
4 /* */
5 /* This file is part of the VIGRA computer vision library. */
6 /* The VIGRA Website is */
7 /* http://hci.iwr.uni-heidelberg.de/vigra/ */
8 /* Please direct questions, bug reports, and contributions to */
9 /* ullrich.koethe@iwr.uni-heidelberg.de or */
10 /* vigra@informatik.uni-hamburg.de */
11 /* */
12 /* Permission is hereby granted, free of charge, to any person */
13 /* obtaining a copy of this software and associated documentation */
14 /* files (the "Software"), to deal in the Software without */
15 /* restriction, including without limitation the rights to use, */
16 /* copy, modify, merge, publish, distribute, sublicense, and/or */
17 /* sell copies of the Software, and to permit persons to whom the */
18 /* Software is furnished to do so, subject to the following */
19 /* conditions: */
20 /* */
21 /* The above copyright notice and this permission notice shall be */
22 /* included in all copies or substantial portions of the */
23 /* Software. */
24 /* */
25 /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND */
26 /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES */
27 /* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND */
28 /* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT */
29 /* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, */
30 /* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING */
31 /* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR */
32 /* OTHER DEALINGS IN THE SOFTWARE. */
33 /* */
34 /************************************************************************/
35
36 #ifndef VIGRA_TUPLE_HXX
37 #define VIGRA_TUPLE_HXX
38
39 #include <utility> // for pair
40
41 namespace vigra {
42
43 /** \page TupleTypes Tuple Types
44
45 pair, triple, tuple4, tuple5
46
47 <b>\#include</b> <vigra/utilities.hxx><br>
48 Namespace: vigra
49
50 VIGRA defines tuple types \p vigra::triple, \p vigra::tuple4, \p vigra::tuple5.
51 In addition, \p std::pair is imported into namespace vigra from the C++ standard
52 library. All these types are defined similarly:
53
54 <ul>
55
56 <li> They are parameterized by the respective number of types. For each tuple,
57 a constructor is defined that takes that many arguments, e.g.:
58 \code
59 template <class First, class Second, class Third>
60 class Triple { ... };
61 \endcode
62 </li>
63 <li> A number of \p typedef's tells the types stored in the tuple:
64
65 \code
66 typedef ... first_type;
67 typedef ... second_type;
68 typedef ... third_type; // triple, tuple4, tuple5 only
69 typedef ... forth_type; // tuple4, tuple5 only
70 typedef ... fifth_type; // tuple5 only
71 \endcode
72 </li>
73 <li> Items are stored in the following public attributes:
74
75 \code
76
77 first;
78 second;
79 third; // triple, tuple4, tuple5 only
80 forth; // tuple4, tuple5 only
81 fifth; // tuple5 only
82
83 \endcode
84 </li>
85 </ul>
86
87
88 */
89
90 /********************************************************/
91 /* */
92 /* pair */
93 /* */
94 /********************************************************/
95
96 using std::pair;
97
98 /********************************************************/
99 /* */
100 /* triple */
101 /* */
102 /********************************************************/
103
104 template <class T1, class T2, class T3>
105 struct triple {
106 typedef T1 first_type;
107 typedef T2 second_type;
108 typedef T3 third_type;
109
110 T1 first;
111 T2 second;
112 T3 third;
113 triple() {}
114 triple(const T1& a, const T2& b, const T3& c)
115 : first(a), second(b), third(c) {}
116 };
117
118 template <class T1, class T2, class T3>
119 triple<T1,T2,T3> make_triple( T1 t1, T2 t2, T3 t3 )
120 { return triple<T1,T2,T3>( t1, t2, t3 ); }
121
122 /********************************************************/
123 /* */
124 /* tuple4 */
125 /* */
126 /********************************************************/
127
128 template <class T1, class T2, class T3, class T4>
129 struct tuple4 {
130 typedef T1 first_type;
131 typedef T2 second_type;
132 typedef T3 third_type;
133 typedef T4 fourth_type;
134
135 T1 first;
136 T2 second;
137 T3 third;
138 T4 fourth;
139 tuple4() {}
140 tuple4(const T1& a, const T2& b, const T3& c, const T4& d)
141 : first(a), second(b), third(c), fourth(d) {}
142 };
143
144 template <class T1, class T2, class T3, class T4>
145 tuple4<T1,T2,T3,T4> make_tuple4( T1 t1, T2 t2, T3 t3, T4 t4 )
146 { return tuple4<T1,T2,T3,T4>( t1, t2, t3, t4 ); }
147
148 /********************************************************/
149 /* */
150 /* tuple5 */
151 /* */
152 /********************************************************/
153
154 template <class T1, class T2, class T3, class T4, class T5>
155 struct tuple5 {
156 typedef T1 first_type;
157 typedef T2 second_type;
158 typedef T3 third_type;
159 typedef T4 fourth_type;
160 typedef T5 fifth_type;
161
162 T1 first;
163 T2 second;
164 T3 third;
165 T4 fourth;
166 T5 fifth;
167 tuple5() {}
168 tuple5(const T1& a, const T2& b, const T3& c, const T4& d, const T5& e)
169 : first(a), second(b), third(c), fourth(d), fifth(e) {}
170 };
171
172 template <class T1, class T2, class T3, class T4, class T5>
173 tuple5<T1,T2,T3,T4,T5> make_tuple5( T1 t1, T2 t2, T3 t3, T4 t4, T5 t5 )
174 { return tuple5<T1,T2,T3,T4,T5>( t1, t2, t3, t4, t5 ); }
175
176
177 } // namespace vigra
178
179
180
181 #endif /* VIGRA_TUPLE_HXX */

© Ullrich Köthe (ullrich.koethe@iwr.uni-heidelberg.de) Heidelberg Collaboratory for Image Processing, University of Heidelberg, Germany | html generated using doxygen and Python vigra 1.11.1 (Fri May 19 2017)