#ifndef __RWEPAUX_H__
#define __RWEPAUX_H__

/***************************************************************************
 *
 * epaux.h - helper components for pointer-based STL wrapper classes
 *   
 * $Id: epaux.h,v 7.25 1996/03/24 18:58:38 pearson Exp $
 *
 * (c) Copyright 1989 - 1996 Rogue Wave Software, Inc.
 * ALL RIGHTS RESERVED
 *
 * The software and information contained herein are proprietary to, and
 * comprise valuable trade secrets of, Rogue Wave Software, Inc., which
 * intends to preserve as trade secrets such software and information.
 * This software is furnished 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 software and information or any other copies thereof may
 * not be provided or otherwise made available to any other person.
 *
 * Notwithstanding any other lease or license that may pertain to, or
 * accompany the delivery of, this computer software and information, the
 * rights of the Government regarding its use, reproduction and disclosure
 * are as set forth in Section 52.227-19 of the FARS Computer
 * Software-Restricted Rights clause.
 * 
 * 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.
 * Contractor/Manufacturer is Rogue Wave Software, Inc.,
 * P.O. Box 2328, Corvallis, Oregon 97339.
 *
 * This computer software and information is distributed with "restricted
 * rights."  Use, duplication or disclosure is subject to restrictions as
 * set forth in NASA FAR SUP 18-52.227-79 (April 1985) "Commercial
 * Computer Software-Restricted Rights (April 1985)."  If the Clause at
 * 18-52.227-74 "Rights in Data General" is specified in the contract,
 * then the "Alternate III" clause applies.
 *
 ****************************************************************************
 * 
 * $Log: epaux.h,v $
 * Revision 7.25  1996/03/24 18:58:38  pearson
 * #2932 - Added #include<utility> to source in definitions for binary_function,
 *         etc.
 *
 * Revision 7.24  1996/03/14 23:58:03  kyle
 * Updated support for RW_HEADER_WITH_EXTENSION
 *
 * Revision 7.23  1996/02/18 01:41:03  griswolf
 * Replace tabs with spaces, per Rogue Wave standard.
 *
 * Revision 7.22  1996/01/30 01:40:28  pearson
 * Fix typo
 *
 * Revision 7.21  1996/01/29  23:58:00  pearson
 * Reverse sense of RW_NO_NEW_HEADERS
 *
 * Revision 7.20  1996/01/29 18:17:49  kyle
 * Millenium added support for pre-C++ Standard headers using
 * RWSTD_NO_NEW_HEADER config define
 *
 * Revision 7.19  1996/01/24 21:07:41  jims
 * Simplify implementation of otis-stl ptr-based collections
 * by using container<T*> impls instead of container<void*>
 *
 * Revision 7.18  1996/01/02 15:56:47  pearson
 * Replaced remaining const modifiers in the first half of pair with the
 * RWCONST macro
 *
 * Revision 7.18  1995/12/21 19:10:37  pearson
 * Replaced remaining const modifiers in the first half of pair with
 * the RWCONST macro
 *
 * Revision 7.17  1995/12/15 18:18:23  pearson
 * Changed RW_INLINE_FRIEND to RW_INLINE_TMPL_FRIEND
 *
 * Revision 7.16  1995/12/15 17:33:24  pearson
 * Add back inline specifier to function definitions
 *
 * Revision 7.15  1995/12/15 17:17:25  pearson
 * Used RW_INLINE_FRIEND because some compilers do not allow inlined friends
 *
 * Revision 7.14  1995/12/11 22:30:41  jims
 * Remove 'Sca' from interior class names
 * Add 'rw_' to global helper classes
 * Change 'muterator' to 'filterator'
 *
 * Revision 7.13  1995/11/17 08:19:27  jims
 * Make operator*() const
 * Adjust const attributes in casting functors
 *
 * Revision 7.12  1995/10/27 16:07:23  jims
 * Port to cset
 *
 * Revision 7.11  1995/10/20  06:48:20  jims
 * port to msvc 4.0: define inline friends outside of the class
 *
 * Revision 7.10  1995/10/11  22:36:45  griswolf
 * Scopus #2160: pass more constructor args through to implementation.
 *
 * Revision 7.9  1995/09/15  20:21:16  griswolf
 * Remove empty body for pair<...>::operator=(pair<...>) to snuff
 * warning.
 *
 * Revision 7.8  1995/09/05  21:42:21  jims
 * Change tlyrs.h to tlyrs.str
 *
 * Revision 7.7  1995/08/31  12:03:51  jims
 * next rev
 *
 * Revision 7.6  1995/08/21  03:37:06  jims
 * remove & (reference) from template params to iterator base structs
 *
 * Revision 7.5  1995/08/11  22:09:10  jims
 * Port to SL1007 / bcc45
 *
 * Revision 7.4  1995/07/27  22:02:33  jims
 * Add header with file name, short description, $Id and $Log
 *
 ****************************************************************************/

#ifndef RW_HEADER_WITH_EXTENSION
# include <iterator>
# include <functional>
# include <utility>
#else
# include <utility.hpp>
# include <iterator.hpp>
# include <function.hpp>
#endif


#ifdef RWSTD_NO_CONST_INST
#  define RWCONST            /* #undef'd below */
#else
#  define RWCONST const      /* #undef'd below */
#endif

template <class T, class U>
struct rw_deref_pair_equal
: binary_function<const pair<T*RWCONST, U*>&,
                  const pair<T*RWCONST, U*>&, bool>
{
  bool operator()(const pair<T*RWCONST, U*>& x,
                  const pair<T*RWCONST, U*>& y) const
  { return *x.first == *y.first && *x.second == *y.second; }
};

template <class T, class U>
struct rw_deref_pair_less
: binary_function<const pair<T*RWCONST, U*>&,
                  const pair<T*RWCONST, U*>&, bool>
{
  bool operator()(const pair<T*RWCONST, U*>& x,
                  const pair<T*RWCONST, U*>& y) const
    { return (*x.first < *y.first) || ( !(*x.first < *y.first) &&
                                         (*x.second < *y.second) ) ; }
};

template <class Compare, class T>
struct rw_deref_compare : public binary_function<T*, T*, bool> {
  Compare cmp_;  
  rw_deref_compare(const Compare& c=Compare()) : cmp_(c) {}
  bool operator()(const T* x, const T* y) const
      { return cmp_(*x,*y); }
};

template <class Hash, class T>
struct rw_deref_hash : public unary_function<T*, unsigned> {
  Hash hash_;
  rw_deref_hash(const Hash& h=Hash()) : hash_(h) {}
  unsigned operator()(const T* x) const
      { return hash_(*x); }
};

#undef RWCONST

#endif /* __RWEPAUX_H__ */
