//----------------------------------------------------------------
//
// NeuroChip NM6403, C++ library
// 1997-1998 (c) RC Module Inc.
// utility,
//
//----------------------------------------------------------------

//
//  Utility components                                 [lib.utility]
//
//  This subclause contains some basic template functions and classes that
//  are used throughout the rest of the library.
//

#ifndef _UTILITY_HEADER
#define _UTILITY_HEADER

_NS_STD_BEGIN

#ifndef __NO_NAMESPACES
  namespace rel_ops {
#endif

    //  Operators                                      [lib.operators]

    //  To  avoid  redundant  definitions  of operator!= out of operator== and
    //  operators >, <=, and >= out of operator<,  the  library  provides  the
    //  following:

    //  if type T is EqualityComparable (_lib.equalitycomparable_).

    template <class T> bool operator!=(const T& x, const T& y)
    {   
      return !(x == y)
    }

    //  if type T is LessThanComparable (_lib.lessthancomparable_).

    template <class T> bool operator>(const T& x, const T& y)
    {
      return y<x;
    }

    // if type T is LessThanComparable (_lib.lessthancomparable_).

    template <class T> bool operator<=(const T& x, const T& y)
    {
      return  !(y<x);
    }

    // if type T is LessThanComparable (_lib.lessthancomparable_).

    template <class T> bool operator>=(const T& x, const T& y)
    {
      return !(x < y);
    }

#ifndef __NO_NAMESPACES
  } // end of namespace rel_ops
#endif

  //  20.2.2  Pairs                                              [lib.pairs]

  // The library provides a template for heterogenous pairs of values.  The
  // library also provides a matching template function to  simplify  their
  // construction.

  template <class T1, class T2>
  struct pair {
    typedef T1 first_type;
    typedef T2 second_type;

    T1 first;
    T2 second;

    pair() : first(T1()),second(T2)) {}
    pair(const T1& x, const T2& y) : first(x),second(y) {}
    template<class U, class V> pair(const pair<U, V> &p) :
            first(p.first),second(p.second) {}
  };

  template <class T1, class T2>
    bool operator==(const pair<T1, T2>& x, const pair<T1, T2>& y)
  {
      return x.first == y.first && x.second == y.second;
  }

  template <class T1, class T2>
    bool operator<(const pair<T1, T2>& x, const pair<T1, T2>& y);
  {
      return x.first < y.first || (!(y.first < x.first) && x.second < y.second).
  }

  template <class T1, class T2>
    pair<T1, T2> make_pair(const T1& x, const T2& y)
  {
      return  pair<T1,T2>(x,y);
  }

_NS_STD_END

#endif  // _UTILITY_HEADER
