[ VIGRA Homepage | Class Index | Function Index | File Index | Main Page ]
![]() |
vigra/tuple.hxx | ![]() |
---|
00001 /************************************************************************/ 00002 /* */ 00003 /* Copyright 1998-2002 by Ullrich Koethe */ 00004 /* Cognitive Systems Group, University of Hamburg, Germany */ 00005 /* */ 00006 /* This file is part of the VIGRA computer vision library. */ 00007 /* ( Version 1.2.0, Aug 07 2003 ) */ 00008 /* You may use, modify, and distribute this software according */ 00009 /* to the terms stated in the LICENSE file included in */ 00010 /* the VIGRA distribution. */ 00011 /* */ 00012 /* The VIGRA Website is */ 00013 /* http://kogs-www.informatik.uni-hamburg.de/~koethe/vigra/ */ 00014 /* Please direct questions, bug reports, and contributions to */ 00015 /* koethe@informatik.uni-hamburg.de */ 00016 /* */ 00017 /* THIS SOFTWARE IS PROVIDED AS IS AND WITHOUT ANY EXPRESS OR */ 00018 /* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED */ 00019 /* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ 00020 /* */ 00021 /************************************************************************/ 00022 00023 #ifndef VIGRA_TUPLE_HXX 00024 #define VIGRA_TUPLE_HXX 00025 00026 #include <utility> // for pair 00027 00028 namespace vigra { 00029 00030 /*! \page TupleTypes Tuple Types 00031 00032 pair, triple, tuple4, tuple5 00033 00034 <b>\#include</b> "<a href="utilities_8hxx-source.html">vigra/utilities.hxx</a>"<br> 00035 Namespace: vigra 00036 00037 VIGRA defines tuple types \p vigra::triple, \p vigra::tuple4, \p vigra::tuple5. 00038 In addition, \p std::pair is imported into namespace vigra from the C++ standard 00039 library. All these types are defined similarly: 00040 00041 <ul> 00042 00043 <li> They are parameterized by the respective number of types. For each tuple, 00044 a constructor is defined that takes that many arguments, e.g.: 00045 \code 00046 template <class First, class Second, class Third> 00047 class Triple { ... }; 00048 \endcode 00049 </li> 00050 <li> A number of \p typedef's tells the types stored in the tuple: 00051 00052 \code 00053 typedef ... first_type; 00054 typedef ... second_type; 00055 typedef ... third_type; // triple, tuple4, tuple5 only 00056 typedef ... forth_type; // tuple4, tuple5 only 00057 typedef ... fifth_type; // tuple5 only 00058 \endcode 00059 </li> 00060 <li> Items are stored in the following public attributes: 00061 00062 \code 00063 00064 first; 00065 second; 00066 third; // triple, tuple4, tuple5 only 00067 forth; // tuple4, tuple5 only 00068 fifth; // tuple5 only 00069 00070 \endcode 00071 </li> 00072 </ul> 00073 00074 00075 */ 00076 00077 /********************************************************/ 00078 /* */ 00079 /* pair */ 00080 /* */ 00081 /********************************************************/ 00082 00083 using std::pair; 00084 00085 /********************************************************/ 00086 /* */ 00087 /* triple */ 00088 /* */ 00089 /********************************************************/ 00090 00091 template <class T1, class T2, class T3> 00092 struct triple { 00093 typedef T1 first_type; 00094 typedef T2 second_type; 00095 typedef T3 third_type; 00096 00097 T1 first; 00098 T2 second; 00099 T3 third; 00100 triple() {} 00101 triple(const T1& a, const T2& b, const T3& c) 00102 : first(a), second(b), third(c) {} 00103 }; 00104 00105 template <class T1, class T2, class T3> 00106 triple<T1,T2,T3> make_triple( T1 t1, T2 t2, T3 t3 ) 00107 { return triple<T1,T2,T3>( t1, t2, t3 ); } 00108 00109 /********************************************************/ 00110 /* */ 00111 /* tuple4 */ 00112 /* */ 00113 /********************************************************/ 00114 00115 template <class T1, class T2, class T3, class T4> 00116 struct tuple4 { 00117 typedef T1 first_type; 00118 typedef T2 second_type; 00119 typedef T3 third_type; 00120 typedef T4 fourth_type; 00121 00122 T1 first; 00123 T2 second; 00124 T3 third; 00125 T4 fourth; 00126 tuple4() {} 00127 tuple4(const T1& a, const T2& b, const T3& c, const T4& d) 00128 : first(a), second(b), third(c), fourth(d) {} 00129 }; 00130 00131 template <class T1, class T2, class T3, class T4> 00132 tuple4<T1,T2,T3,T4> make_tuple4( T1 t1, T2 t2, T3 t3, T4 t4 ) 00133 { return tuple4<T1,T2,T3,T4>( t1, t2, t3, t4 ); } 00134 00135 /********************************************************/ 00136 /* */ 00137 /* tuple5 */ 00138 /* */ 00139 /********************************************************/ 00140 00141 template <class T1, class T2, class T3, class T4, class T5> 00142 struct tuple5 { 00143 typedef T1 first_type; 00144 typedef T2 second_type; 00145 typedef T3 third_type; 00146 typedef T4 fourth_type; 00147 typedef T5 fifth_type; 00148 00149 T1 first; 00150 T2 second; 00151 T3 third; 00152 T4 fourth; 00153 T5 fifth; 00154 tuple5() {} 00155 tuple5(const T1& a, const T2& b, const T3& c, const T4& d, const T5& e) 00156 : first(a), second(b), third(c), fourth(d), fifth(e) {} 00157 }; 00158 00159 template <class T1, class T2, class T3, class T4, class T5> 00160 tuple5<T1,T2,T3,T4,T5> make_tuple5( T1 t1, T2 t2, T3 t3, T4 t4, T5 t5 ) 00161 { return tuple5<T1,T2,T3,T4,T5>( t1, t2, t3, t4, t5 ); } 00162 00163 00164 } // namespace vigra 00165 00166 00167 00168 #endif /* VIGRA_TUPLE_HXX */
© Ullrich Köthe (koethe@informatik.uni-hamburg.de) |
html generated using doxygen and Python
|