1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright held by original author
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
11 OpenFOAM is free software; you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published by the
13 Free Software Foundation; either version 2 of the License, or (at your
14 option) any later version.
16 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM; if not, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
32 Foam::Pair for storing two objects of identical types.
34 \*---------------------------------------------------------------------------*/
41 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
46 // Forward declaration of friend functions and operators
48 template<class Type1, class Type2>
51 template<class Type1, class Type2>
52 inline bool operator==
54 const Tuple2<Type1, Type2>&,
55 const Tuple2<Type1, Type2>&
58 template<class Type1, class Type2>
59 inline bool operator!=
61 const Tuple2<Type1, Type2>&,
62 const Tuple2<Type1, Type2>&
65 template<class Type1, class Type2>
66 inline Istream& operator>>(Istream&, Tuple2<Type1, Type2>&);
68 template<class Type1, class Type2>
69 inline Ostream& operator<<(Ostream&, const Tuple2<Type1, Type2>&);
72 /*---------------------------------------------------------------------------*\
73 class Tuple2 Declaration
74 \*---------------------------------------------------------------------------*/
76 template<class Type1, class Type2>
89 //- Null constructor for lists
93 //- Construct from components
94 inline Tuple2(const Type1& f, const Type2& s)
100 //- Construct from Istream
101 inline Tuple2(Istream& is)
110 inline const Type1& first() const
116 inline Type1& first()
122 inline const Type2& second() const
128 inline Type2& second()
133 //- Return reverse pair
134 inline Tuple2<Type2, Type1> reverseTuple2() const
136 return Tuple2<Type2, Type1>(second(), first());
142 friend bool operator== <Type1, Type2>
144 const Tuple2<Type1, Type2>& a,
145 const Tuple2<Type1, Type2>& b
148 friend bool operator!= <Type1, Type2>
150 const Tuple2<Type1, Type2>& a,
151 const Tuple2<Type1, Type2>& b
155 // IOstream operators
157 //- Read Tuple2 from Istream, discarding contents of existing Tuple2.
158 friend Istream& operator>> <Type1, Type2>
161 Tuple2<Type1, Type2>& t2
164 // Write Tuple2 to Ostream.
165 friend Ostream& operator<< <Type1, Type2>
168 const Tuple2<Type1, Type2>& t2
173 template<class Type1, class Type2>
174 inline bool operator==
176 const Tuple2<Type1, Type2>& a,
177 const Tuple2<Type1, Type2>& b
182 (a.first() == b.first()) && (a.second() == b.second())
187 template<class Type1, class Type2>
188 inline bool operator!=
190 const Tuple2<Type1, Type2>& a,
191 const Tuple2<Type1, Type2>& b
198 template<class Type1, class Type2>
199 inline Istream& operator>>(Istream& is, Tuple2<Type1, Type2>& t2)
201 is.readBegin("Tuple2");
202 is >> t2.f_ >> t2.s_;
203 is.readEnd("Tuple2");
205 // Check state of Istream
206 is.check("operator>>(Istream&, Tuple2<Type1, Type2>&)");
212 template<class Type1, class Type2>
213 inline Ostream& operator<<(Ostream& os, const Tuple2<Type1, Type2>& t2)
215 os << token::BEGIN_LIST
216 << t2.f_ << token::SPACE << t2.s_
223 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
225 } // End namespace Foam
227 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
231 // ************************************************************************* //