home *** CD-ROM | disk | FTP | other *** search
/ DOS/V Power Report 1997 May / VPR9705A.ISO / VPR_DATA / PROGRAM / CBTRIAL / SETUP / DATA.Z / UTILITY.H < prev    next >
C/C++ Source or Header  |  1997-02-14  |  4KB  |  137 lines

  1. #ifndef __STD_UTILITY__
  2. #define __STD_UTILITY__
  3. /* $Revision:   8.1  $ */
  4.  
  5. /***************************************************************************
  6.  *
  7.  * utility - Declarations for the Standard Library utility classes
  8.  *
  9.  * $Id: utility,v 1.15 1995/08/15 00:07:49 smithey Exp $
  10.  *
  11.  ***************************************************************************
  12.  *
  13.  * Copyright (c) 1994
  14.  * Hewlett-Packard Company
  15.  *
  16.  * Permission to use, copy, modify, distribute and sell this software
  17.  * and its documentation for any purpose is hereby granted without fee,
  18.  * provided that the above copyright notice appear in all copies and
  19.  * that both that copyright notice and this permission notice appear
  20.  * in supporting documentation.  Hewlett-Packard Company makes no
  21.  * representations about the suitability of this software for any
  22.  * purpose.  It is provided "as is" without express or implied warranty.
  23.  *
  24.  *
  25.  ***************************************************************************
  26.  *
  27.  * (c) Copyright 1994, 1995 Rogue Wave Software, Inc.
  28.  * ALL RIGHTS RESERVED
  29.  *
  30.  * The software and information contained herein are proprietary to, and
  31.  * comprise valuable trade secrets of, Rogue Wave Software, Inc., which
  32.  * intends to preserve as trade secrets such software and information.
  33.  * This software is furnished pursuant to a written license agreement and
  34.  * may be used, copied, transmitted, and stored only in accordance with
  35.  * the terms of such license and with the inclusion of the above copyright
  36.  * notice.  This software and information or any other copies thereof may
  37.  * not be provided or otherwise made available to any other person.
  38.  *
  39.  * Notwithstanding any other lease or license that may pertain to, or
  40.  * accompany the delivery of, this computer software and information, the
  41.  * rights of the Government regarding its use, reproduction and disclosure
  42.  * are as set forth in Section 52.227-19 of the FARS Computer
  43.  * Software-Restricted Rights clause.
  44.  *
  45.  * Use, duplication, or disclosure by the Government is subject to
  46.  * restrictions as set forth in subparagraph (c)(1)(ii) of the Rights in
  47.  * Technical Data and Computer Software clause at DFARS 252.227-7013.
  48.  * Contractor/Manufacturer is Rogue Wave Software, Inc.,
  49.  * P.O. Box 2328, Corvallis, Oregon 97339.
  50.  *
  51.  * This computer software and information is distributed with "restricted
  52.  * rights."  Use, duplication or disclosure is subject to restrictions as
  53.  * set forth in NASA FAR SUP 18-52.227-79 (April 1985) "Commercial
  54.  * Computer Software-Restricted Rights (April 1985)."  If the Clause at
  55.  * 18-52.227-74 "Rights in Data General" is specified in the contract,
  56.  * then the "Alternate III" clause applies.
  57.  *
  58.  **************************************************************************/
  59.  
  60. #include <stdcomp.h>
  61.  
  62. #ifndef RWSTD_NO_NAMESPACE
  63. namespace std {
  64. #endif
  65.  
  66. //
  67. // Operators
  68. //
  69.  
  70. template <class T>
  71. inline bool operator!=(const T& x, const T& y)
  72. {
  73.     return !(x == y);
  74. }
  75.  
  76. template <class T>
  77. inline bool operator>(const T& x, const T& y)
  78. {
  79.     return y < x;
  80. }
  81.  
  82. template <class T>
  83. inline bool operator<=(const T& x, const T& y)
  84. {
  85.     return !(y < x);
  86. }
  87.  
  88. template <class T>
  89. inline bool operator>=(const T& x, const T& y)
  90. {
  91.     return !(x < y);
  92. }
  93.  
  94. //
  95. // Pairs.
  96. //
  97.  
  98. template <class T1, class T2>
  99. struct pair
  100. {
  101.     T1 first;
  102.     T2 second;
  103.     pair (const T1& a, const T2& b) : first(a), second(b) {}
  104. #ifdef RWSTD_NO_MEMBER_WO_DEF_CTOR
  105.     pair ()
  106. #ifndef RWSTD_NO_BUILT_IN_CTOR
  107. : first(T1()), second(T2())
  108. #endif
  109.     { ; }
  110. #endif
  111.     ~pair () {;} // To avoid xlC warnings when destroy is called.
  112. };
  113.  
  114. template <class T1, class T2>
  115. inline bool operator==(const pair<T1, T2>& x, const pair<T1, T2>& y)
  116. {
  117.     return x.first == y.first && x.second == y.second;
  118. }
  119.  
  120. template <class T1, class T2>
  121. inline bool operator<(const pair<T1, T2>& x, const pair<T1, T2>& y)
  122. {
  123.     return x.first < y.first || (!(y.first < x.first) && x.second < y.second);
  124. }
  125.  
  126. template <class T1, class T2>
  127. inline pair<T1, T2> make_pair(const T1& x, const T2& y)
  128. {
  129.     return pair<T1, T2>(x, y);
  130. }
  131.  
  132. #ifndef RWSTD_NO_NAMESPACE
  133. }
  134. #endif
  135.  
  136. #endif /*__STD_UTILITY__*/
  137.