src/hugo/extended_pair.h
author alpar
Mon, 13 Sep 2004 11:24:35 +0000
changeset 835 eb9587f09b42
child 897 ef09eee53b09
permissions -rw-r--r--
Remove one remaining range checking.
deba@782
     1
// -*- c++ -*-
deba@782
     2
#ifndef EXTENDED_PAIR_H
deba@782
     3
#define EXTENDED_PAIR_H
deba@782
     4
deba@782
     5
template <typename T1, typename A1, typename T2, typename A2>
deba@782
     6
struct extended_pair {
deba@782
     7
  typedef T1 first_type;
deba@782
     8
  typedef T2 second_type;
deba@782
     9
deba@782
    10
  extended_pair() : first(), second() {}
deba@782
    11
deba@782
    12
  extended_pair(A1 f, A2 s) : first(f), second(s) {}
deba@782
    13
deba@782
    14
  template <class Pair>
deba@782
    15
  extended_pair(const Pair& pair) : first(pair.first), second(pair.second) {}
deba@782
    16
deba@782
    17
  T1 first;
deba@782
    18
  T2 second;
deba@782
    19
};
deba@782
    20
deba@782
    21
template <typename T1, typename T2, 
deba@782
    22
	  typename LA1, typename LA2, typename RA1, typename RA2>
deba@782
    23
bool operator==(const extended_pair<T1, LA1, T2, LA2>& left, 
deba@782
    24
		const extended_pair<T1, RA1, T2, RA2>& right) {
deba@782
    25
  return left.first == right.first && left.second == right.second;
deba@782
    26
}
deba@782
    27
deba@782
    28
template <typename T1, typename T2, 
deba@782
    29
	  typename LA1, typename LA2, typename RA1, typename RA2>
deba@782
    30
bool operator!=(const extended_pair<T1, LA1, T2, LA2>& left, 
deba@782
    31
		const extended_pair<T1, RA1, T2, RA2>& right) {
deba@782
    32
  return  !(left == right);
deba@782
    33
}
deba@782
    34
deba@782
    35
template <typename T1, typename T2, 
deba@782
    36
	  typename LA1, typename LA2, typename RA1, typename RA2>
deba@782
    37
bool operator<(const extended_pair<T1, LA1, T2, LA2>& left, 
deba@782
    38
		const extended_pair<T1, RA1, T2, RA2>& right) {
deba@782
    39
  if (left.first == right.first) return left.second == right.second;
deba@782
    40
  return left.first < right.first;
deba@782
    41
}
deba@782
    42
deba@782
    43
template <typename T1, typename T2, 
deba@782
    44
	  typename LA1, typename LA2, typename RA1, typename RA2>
deba@782
    45
bool operator>(const extended_pair<T1, LA1, T2, LA2>& left, 
deba@782
    46
		const extended_pair<T1, RA1, T2, RA2>& right) {
deba@782
    47
  return right < left;
deba@782
    48
}
deba@782
    49
deba@782
    50
template <typename T1, typename T2, 
deba@782
    51
	  typename LA1, typename LA2, typename RA1, typename RA2>
deba@782
    52
bool operator<=(const extended_pair<T1, LA1, T2, LA2>& left, 
deba@782
    53
		const extended_pair<T1, RA1, T2, RA2>& right) {
deba@782
    54
  return !(right > left);
deba@782
    55
}
deba@782
    56
deba@782
    57
template <typename T1, typename T2, 
deba@782
    58
	  typename LA1, typename LA2, typename RA1, typename RA2>
deba@782
    59
bool operator>=(const extended_pair<T1, LA1, T2, LA2>& left, 
deba@782
    60
		const extended_pair<T1, RA1, T2, RA2>& right) {
deba@782
    61
  return !(right < left);
deba@782
    62
}
deba@782
    63
deba@782
    64
deba@782
    65
#endif