src/utility/triple.h

Go to the documentation of this file.
00001 /***************************************************************************
00002                           triple.h  -  description
00003                              -------------------
00004     begin                : Mon Dec 15 2003
00005     copyright            : (C) 2003 by Roman Geus
00006     email                : roman.geus@psi.ch
00007 ***************************************************************************/
00008 
00009 /***************************************************************************
00010  *                                                                         *
00011  *   This program is free software; you can redistribute it and/or modify  *
00012  *   it under the terms of the GNU General Public License as published by  *
00013  *   the Free Software Foundation; either version 2 of the License, or     *
00014  *   (at your option) any later version.                                   *
00015  *                                                                         *
00016  ***************************************************************************/
00017 
00018 #ifndef tripleH
00019 #define tripleH
00020 
00021 namespace utility {
00022 
00024 template <class _T1, class _T2, class _T3>
00025 struct triple {
00026     typedef _T1 first_type;    
00027     typedef _T2 second_type;   
00028     typedef _T3 third_type;    
00029 
00030     _T1 first;                 
00031     _T2 second;                
00032     _T3 third;                 
00033 #ifdef _GLIBCPP_RESOLVE_LIB_DEFECTS
00034     //265.  std::triple::triple() effects overly restrictive
00037     triple() : first(), second(), third() {}
00038 #else
00039     triple() : first(_T1()), second(_T2()), third(_T3()) {}
00040 #endif
00041 
00042     triple(const _T1& __a, const _T2& __b, const _T3& __c) : first(__a), second(__b), third(__c) {}
00043 
00045     template <class _U1, class _U2, class _U3>
00046     triple(const triple<_U1, _U2, _U3>& __p) : first(__p.first), second(__p.second), third(__p.third) {}
00047 };
00048 
00050 template <class _T1, class _T2, class _T3>
00051 inline bool operator==(const triple<_T1, _T2, _T3>& __x, const triple<_T1, _T2, _T3>& __y)
00052 {
00053     return __x.first == __y.first && __x.second == __y.second && __x.third == __y.third;
00054 }
00055 
00057 template <class _T1, class _T2, class _T3>
00058 inline bool operator<(const triple<_T1, _T2, _T3>& __x, const triple<_T1, _T2, _T3>& __y)
00059 {
00060     return __x.first < __y.first ||
00061         (!(__y.first < __x.first) && __x.second < __y.second) ||
00062         (!(__y.first < __x.first) && !(__y.second < __x.second) && __x.third < __y.third);
00063 }
00064 
00066 template <class _T1, class _T2, class _T3>
00067 inline bool operator!=(const triple<_T1, _T2, _T3>& __x, const triple<_T1, _T2, _T3>& __y) {
00068     return !(__x == __y);
00069 }
00070 
00072 template <class _T1, class _T2, class _T3>
00073 inline bool operator>(const triple<_T1, _T2, _T3>& __x, const triple<_T1, _T2, _T3>& __y) {
00074     return __y < __x;
00075 }
00076 
00078 template <class _T1, class _T2, class _T3>
00079 inline bool operator<=(const triple<_T1, _T2, _T3>& __x, const triple<_T1, _T2, _T3>& __y) {
00080     return !(__y < __x);
00081 }
00082 
00084 template <class _T1, class _T2, class _T3>
00085 inline bool operator>=(const triple<_T1, _T2, _T3>& __x, const triple<_T1, _T2, _T3>& __y) {
00086     return !(__x < __y);
00087 }
00088 
00100 template <class _T1, class _T2, class _T3>
00101 #ifdef _GLIBCPP_RESOLVE_LIB_DEFECTS
00102 //181.  make_triple() unintended behavior
00103 inline triple<_T1, _T2, _T3> make_triple(_T1 __x, _T2 __y, _T3 __z)
00104 #else
00105     inline triple<_T1, _T2, _T3> make_triple(const _T1& __x, const _T2& __y, const _T3& __z)
00106 #endif
00107 {
00108     return triple<_T1, _T2, _T3>(__x, __y, __z);
00109 }
00110 
00111 } // namespace utility
00112 
00113 #endif

Generated on Fri Oct 26 13:35:13 2007 for FEMAXX (Finite Element Maxwell Eigensolver) by  doxygen 1.4.7