// -*- C++ -*-
/***************************************************************************
 *
 * utility - Declarations for the Standard Library utility classes
 *
 ***************************************************************************
 *
 * Copyright (c) 1994
 * Hewlett-Packard Company
 *
 * Permission to use, copy, modify, distribute and sell this software
 * and its documentation for any purpose is hereby granted without fee,
 * provided that the above copyright notice appear in all copies and
 * that both that copyright notice and this permission notice appear
 * in supporting documentation.  Hewlett-Packard Company makes no
 * representations about the suitability of this software for any
 * purpose.  It is provided "as is" without express or implied warranty.
 *
 ***************************************************************************
 *
 * Copyright (c) 1994-2001 Rogue Wave Software, Inc.  All Rights Reserved.
 *
 * This computer software is owned by Rogue Wave Software, Inc. and is
 * protected by U.S. copyright laws and other laws and by international
 * treaties.  This computer software is furnished by Rogue Wave Software,
 * Inc. pursuant to a written license agreement and may be used, copied,
 * transmitted, and stored only in accordance with the terms of such
 * license and with the inclusion of the above copyright notice.  This
 * computer software or any other copies thereof may not be provided or
 * otherwise made available to any other person.
 *
 * U.S. Government Restricted Rights.  This computer software is provided
 * with Restricted Rights.  Use, duplication, or disclosure by the
 * Government is subject to restrictions as set forth in subparagraph (c)
 * (1) (ii) of The Rights in Technical Data and Computer Software clause
 * at DFARS 252.227-7013 or subparagraphs (c) (1) and (2) of the
 * Commercial Computer Software--Restricted Rights at 48 CFR 52.227-19,
 * as applicable.  Manufacturer is Rogue Wave Software, Inc., 5500
 * Flatiron Parkway, Boulder, Colorado 80301 USA.
 *
 **************************************************************************/

#ifndef _RWSTD_UTILITY_INCLUDED
#define _RWSTD_UTILITY_INCLUDED

#include <rw/_defs.h>


_RWSTD_NAMESPACE_BEGIN (std)


#ifndef _RWSTD_NO_NAMESPACE

// rel_ops contents not available if namespaces are disabled
// to avoid ambiguities with other overloaded operators

_RWSTD_NAMESPACE_BEGIN (rel_ops)


template <class _TypeT>
inline bool operator!= (const _TypeT& __x, const _TypeT& __y)
{
    return !(__x == __y);
}

template <class _TypeT>
inline bool operator> (const _TypeT& __x, const _TypeT& __y)
{
    return __y < __x;
}

template <class _TypeT>
inline bool operator<= (const _TypeT& __x, const _TypeT& __y)
{
    return !(__y < __x);
}

template <class _TypeT>
inline bool operator>= (const _TypeT& __x, const _TypeT& __y)
{
    return !(__x < __y);
}


_RWSTD_NAMESPACE_END   // rel_ops


#endif   // _RWSTD_NO_NAMESPACE


// 20.2.2
template <class _TypeT, class _TypeU>
struct pair
{
    typedef _TypeT first_type;
    typedef _TypeU second_type;

    first_type  first;
    second_type second;

    pair (const first_type &__x, const second_type &__y)
        : first (__x), second (__y) { }

    pair ()
#ifndef _RWSTD_NO_EMPTY_MEM_INITIALIZER
        : first (/* lwg issue 265 */), second () { }
#else
        : first (first_type ()), second (second_type ()) { }
#endif   // _RWSTD_NO_EMPTY_MEM_INITIALIZER

    pair (const pair &__rhs): first (__rhs.first), second (__rhs.second) { }

#ifndef _RWSTD_NO_MEMBER_TEMPLATES

    template <class _TypeX, class _TypeY>
    pair (const pair <_TypeX, _TypeY> &__rhs) 
        : first (__rhs.first), second (__rhs.second) { }

#endif   // _RWSTD_NO_MEMBER_TEMPLATES

};


template <class _TypeT, class _TypeU>
inline bool
operator== (const pair<_TypeT, _TypeU>& __x, const pair<_TypeT, _TypeU>& __y)
{ 
    return __x.first == __y.first && __x.second == __y.second; 
}


template <class _TypeT, class _TypeU>
inline bool
operator!= (const pair<_TypeT, _TypeU>& __x, const pair<_TypeT, _TypeU>& __y)
{ 
    return !(__x == __y);
}


template <class _TypeT, class _TypeU>
inline bool
operator< (const pair<_TypeT, _TypeU>& __x, const pair<_TypeT, _TypeU>& __y)
{ 
    return    __x.first < __y.first
           || (!(__y.first < __x.first) && __x.second < __y.second); 
}


template <class _TypeT, class _TypeU>
inline bool
operator> (const pair<_TypeT, _TypeU>& __x, const pair<_TypeT, _TypeU>& __y)
{ 
    return __y < __x;
}


template <class _TypeT, class _TypeU>
inline bool
operator>= (const pair<_TypeT, _TypeU>& __x, const pair<_TypeT, _TypeU>& __y)
{ 
    return !(__x < __y);
}


template <class _TypeT, class _TypeU>
inline bool
operator<= (const pair<_TypeT, _TypeU>& __x, const pair<_TypeT, _TypeU>& __y)
{ 
    return !(__y < __x);
}


template <class _TypeT, class _TypeU>
inline pair<_TypeT, _TypeU>
make_pair (const _TypeT &__x, const _TypeU &__y)
{
    return pair<_TypeT, _TypeU>(__x, __y);
}


_RWSTD_NAMESPACE_END   // std


#endif   // _RWSTD_UTILITY_INCLUDED
