core/vbl/vbl_quadruple.h
Go to the documentation of this file.
00001 // This is core/vbl/vbl_quadruple.h
00002 #ifndef vbl_quadruple_h_
00003 #define vbl_quadruple_h_
00004 #ifdef VCL_NEEDS_PRAGMA_INTERFACE
00005 #pragma interface
00006 #endif
00007 //:
00008 // \file
00009 // \brief a templated 4-tuple
00010 // \author fsm
00011 
00012 #include <vcl_compiler.h>
00013 
00014 //: a templated 4-tuple
00015 template <class T1, class T2, class T3, class T4>
00016 struct vbl_quadruple
00017 {
00018   typedef T1 first_type;
00019   typedef T2 second_type;
00020   typedef T3 third_type;
00021   typedef T4 fourth_type;
00022 
00023   T1 first;
00024   T2 second;
00025   T3 third;
00026   T4 fourth;
00027 
00028   vbl_quadruple() { }
00029   vbl_quadruple(T1 const &a, T2 const &b, T3 const &c, T4 const &d)
00030     : first (a)
00031     , second(b)
00032     , third (c)
00033     , fourth(d) { }
00034 #if VCL_HAS_MEMBER_TEMPLATES
00035   template <class U1, class U2, class U3, class U4>
00036   vbl_quadruple(vbl_quadruple<U1, U2, U3, U4> const &that)
00037     : first (that.first )
00038     , second(that.second)
00039     , third (that.third )
00040     , fourth(that.fourth) { }
00041 #endif
00042 };
00043 
00044 template <class T1, class T2, class T3, class T4>
00045 inline bool operator==(vbl_quadruple<T1, T2, T3, T4> const &x, vbl_quadruple<T1, T2, T3, T4> const &y)
00046 {
00047   return
00048     x.first  == y.first  &&
00049     x.second == y.second &&
00050     x.third  == y.third  &&
00051     x.fourth == y.fourth;
00052 }
00053 
00054 template <class T1, class T2, class T3, class T4>
00055 inline bool operator!=(vbl_quadruple<T1, T2, T3, T4> const &x, vbl_quadruple<T1, T2, T3, T4> const &y)
00056 { return !(x == y); }
00057 
00058 template <class T1, class T2, class T3, class T4>
00059 inline bool operator< (vbl_quadruple<T1, T2, T3, T4> const &x, vbl_quadruple<T1, T2, T3, T4> const &y)
00060 {
00061   return x.first  != y.first  ? x.first  < y.first  :
00062          x.second != y.second ? x.second < y.second :
00063          x.third  != y.third  ? x.third  < y.third  :
00064          x.fourth != y.fourth ? x.fourth < y.fourth :
00065          false;
00066 }
00067 
00068 template <class T1, class T2, class T3, class T4>
00069 inline vbl_quadruple<T1, T2, T3, T4> vbl_make_quadruple(T1 const &x, T2 const &y, T3 const &z, T4 const &w)
00070 {
00071   return vbl_quadruple<T1, T2, T3, T4>(x, y, z, w);
00072 }
00073 
00074 #endif // vbl_quadruple_h_