//  utility : headerfile for the free standard C++ library
//  
//  Copyright (C) 1999 by the free standard C++ Library Team
//                        see AUTHORS for more details
//
//  Homepage : http://www.inf.fu-berlin.de/~mkrueger/fscl/
//
//  This library is free software; you can redistribute it and/or
//  modify it under the terms of the GNU Library General Public
//  License as published by the Free Software Foundation; either	
//  version 2 of the License, or (at your option) any later version.
//
//  This library is distributed in the hope that it will be useful,
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
//  Library General Public License for more details.
//  You should have received a copy of the GNU Library General Public
//  License along with this library; if not, write to the Free
//  Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//
//  version : 0.1 last modified : 17.09.99

#ifndef __CPP_UTILITY
#define __CPP_UTILITY

namespace std {

	// 20.2.1 operators:
	namespace rel_ops {
	
		template<class T> 
		inline bool operator!=(const T& x, const T& y) 
		{
			return !(x == y);
		}
		
		template<class T>
		inline bool operator> (const T& x, const T& y)
		{
			return y < x;
		}
		
		template<class T>
		inline bool operator<=(const T& x, const T& y)
		{
			return !(y < x);
		}

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

	// 20.2.2 pairs:
	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> 
	inline 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>
	inline 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);
	}
	using namespace rel_ops;
    
	template <class T1, class T2>
	inline bool operator!=(const pair<T1,T2>& x, const pair<T1,T2>& y) 
	{
		return !(x == y);
	}
    
	template <class T1, class T2>
	inline bool operator> (const pair<T1,T2>& x, const pair<T1,T2>& y) 
	{
		return y < x;
	}

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

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

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

#endif
