Advertisement
Guest User

Untitled

a guest
Jan 5th, 2014
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.55 KB | None | 0 0
  1. template <class T1, class T2, class T3>
  2. class trio {
  3. public:
  4.   T1 first;
  5.   T2 second;
  6.   T3 third;
  7.   trio(T1 first, T2 second, T3 third) : trio::first(first), trio::second(second), trio::third(third) {}
  8.   trio() {}
  9.   trio(const trio &a) : first(a.first), second(a.second), third(a.third) {}
  10.   void swap(trio &a) {
  11.     std::swap(first, a.first);
  12.     std::swap(second, a.second);
  13.     std::swap(third, a.third);
  14.   }
  15.   void operator= (const trio a) {
  16.     first = a.first;
  17.     second = a.second;
  18.     third = a.third;
  19.   }
  20.   bool operator== (const trio b) {
  21.     return (first == b.first && second == b.second && third == b.third);
  22.   }
  23.   bool operator!= (const trio b) {
  24.     return (first != b.first || second != b.second || third != b.third);
  25.   }
  26.   bool operator< (const trio a) {
  27.     if(first==a.first) {
  28.       if(second==a.second)
  29.     return (third<a.third);
  30.       return (second<a.second);
  31.     }
  32.     return (first<a.first);
  33.   }
  34.   bool operator> (const trio a) {
  35.     if(first==a.first) {
  36.       if(second==a.second)
  37.     return (third>a.third);
  38.       return (second>a.second);
  39.     }
  40.     return (first>a.first);
  41.   }
  42.   bool operator<= (const trio a) {
  43.     return (trio<T1, T2, T3> (first, second, third)<a || trio<T1, T2, T3> (first, second, third)==a);
  44.   }
  45.   bool operator>= (const trio a) {
  46.     return (trio<T1, T2, T3> (first, second, third)>a || trio<T1, T2, T3> (first, second, third)==a);
  47.   }
  48. };
  49.  
  50. template <class T1, class T2, class T3>
  51. trio<T1, T2, T3> make_trio(T1 first, T2 second, T3 third) {
  52.   return trio<T1, T2, T3> (first, second, third);
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement