home *** CD-ROM | disk | FTP | other *** search
/ PC Plus SuperCD (UK) 2000 May / PCP163A.iso / Runimage / Cbuilder4 / Include / UTILITY.H < prev    next >
Encoding:
C/C++ Source or Header  |  1999-01-26  |  5.4 KB  |  188 lines

  1. #ifndef __UTILITY_H
  2. #define __UTILITY_H
  3. #pragma option push -b -a8 -pc -Vx- -Ve- -w-inl -w-aus -w-sig
  4. // -*- C++ -*-
  5. #ifndef __STD_UTILITY__
  6. #define __STD_UTILITY__
  7.  
  8. /***************************************************************************
  9.  *
  10.  * utility - Declarations for the Standard Library utility classes
  11.  *
  12.  ***************************************************************************
  13.  *
  14.  * Copyright (c) 1994
  15.  * Hewlett-Packard Company
  16.  *
  17.  * Permission to use, copy, modify, distribute and sell this software
  18.  * and its documentation for any purpose is hereby granted without fee,
  19.  * provided that the above copyright notice appear in all copies and
  20.  * that both that copyright notice and this permission notice appear
  21.  * in supporting documentation.  Hewlett-Packard Company makes no
  22.  * representations about the suitability of this software for any
  23.  * purpose.  It is provided "as is" without express or implied warranty.
  24.  *
  25.  *
  26.  ***************************************************************************
  27.  *
  28.  * (c) Copyright 1994, 1998 Rogue Wave Software, Inc.
  29.  * ALL RIGHTS RESERVED
  30.  *
  31.  * The software and information contained herein are proprietary to, and
  32.  * comprise valuable trade secrets of, Rogue Wave Software, Inc., which
  33.  * intends to preserve as trade secrets such software and information.
  34.  * This software is furnished pursuant to a written license agreement and
  35.  * may be used, copied, transmitted, and stored only in accordance with
  36.  * the terms of such license and with the inclusion of the above copyright
  37.  * notice.  This software and information or any other copies thereof may
  38.  * not be provided or otherwise made available to any other person.
  39.  *
  40.  * Notwithstanding any other lease or license that may pertain to, or
  41.  * accompany the delivery of, this computer software and information, the
  42.  * rights of the Government regarding its use, reproduction and disclosure
  43.  * are as set forth in Section 52.227-19 of the FARS Computer
  44.  * Software-Restricted Rights clause.
  45.  * 
  46.  * Use, duplication, or disclosure by the Government is subject to
  47.  * restrictions as set forth in subparagraph (c)(1)(ii) of the Rights in
  48.  * Technical Data and Computer Software clause at DFARS 252.227-7013.
  49.  * Contractor/Manufacturer is Rogue Wave Software, Inc.,
  50.  * P.O. Box 2328, Corvallis, Oregon 97339.
  51.  *
  52.  * This computer software and information is distributed with "restricted
  53.  * rights."  Use, duplication or disclosure is subject to restrictions as
  54.  * set forth in NASA FAR SUP 18-52.227-79 (April 1985) "Commercial
  55.  * Computer Software-Restricted Rights (April 1985)."  If the Clause at
  56.  * 18-52.227-74 "Rights in Data General" is specified in the contract,
  57.  * then the "Alternate III" clause applies.
  58.  *
  59.  **************************************************************************/
  60.  
  61. #include <stdcomp.h>
  62.  
  63. #ifndef _RWSTD_NO_NAMESPACE
  64. namespace std {
  65. #endif
  66.  
  67. #ifndef _RWSTD_NO_NAMESPACE
  68.   namespace rel_ops {
  69. #endif
  70.  
  71. //
  72. // Operators
  73. //
  74.  
  75.     template <class T>
  76.     inline bool operator!=(const T& x, const T& y)
  77.     {
  78.       return !(x == y);
  79.     }
  80.  
  81.     template <class T>
  82.     inline bool operator>(const T& x, const T& y)
  83.     {
  84.       return y < x;
  85.     }
  86.  
  87.     template <class T>
  88.     inline bool operator<=(const T& x, const T& y)
  89.     {
  90.       return !(y < x);
  91.     }
  92.  
  93.     template <class T>
  94.     inline bool operator>=(const T& x, const T& y)
  95.     {
  96.       return !(x < y);
  97.     }
  98.  
  99. #ifndef _RWSTD_NO_NAMESPACE
  100.   } /* End of namespace rel_ops */
  101. #endif
  102.  
  103. //
  104. // Pairs.
  105. //
  106.  
  107.   template <class T1, class T2>
  108.   struct pair
  109.   {
  110.     typedef T1 first_type;
  111.     typedef T2 second_type;
  112.  
  113.     T1 first;
  114.     T2 second;
  115.     pair (const T1& a, const T2& b) : first(a), second(b) {}
  116.     pair () 
  117. #ifndef _RWSTD_NO_BUILT_IN_CTOR
  118.       : first(T1()), second(T2()) 
  119. #endif
  120.     { ; }
  121.  
  122.     pair(const pair& p) 
  123.       : first(p.first), second(p.second)
  124.     { ; }
  125. #ifndef _RWSTD_NO_MEMBER_TEMPLATES
  126.     template <class U, class V> pair(const pair<U,V>& p) 
  127.       : first(p.first), second(p.second)
  128.     { ; }
  129. #endif
  130.  
  131.     ~pair () {;} // To avoid xlC warnings when destroy is called.
  132.   };
  133.  
  134.   template <class T1, class T2>
  135.   inline bool operator==(const pair<T1, T2>& x, const pair<T1, T2>& y)
  136.   { 
  137.     return x.first == y.first && x.second == y.second; 
  138.   }
  139.  
  140.   template <class T1, class T2>
  141.   inline bool operator<(const pair<T1, T2>& x, const pair<T1, T2>& y)
  142.   { 
  143.     return x.first < y.first || (!(y.first < x.first) && x.second < y.second); 
  144.   }
  145.  
  146. #ifndef _RWSTD_NO_NAMESPACE
  147.   template <class T1, class T2>
  148.   inline bool operator!=(const pair<T1, T2>& x, const pair<T1, T2>& y)
  149.   { 
  150.     return !(x == y);
  151.   }
  152.  
  153.   template <class T1, class T2>
  154.   inline bool operator>(const pair<T1, T2>& x, const pair<T1, T2>& y)
  155.   { 
  156.     return y < x;
  157.   }
  158.  
  159.   template <class T1, class T2>
  160.   inline bool operator>=(const pair<T1, T2>& x, const pair<T1, T2>& y)
  161.   { 
  162.     return !(x < y);
  163.   }
  164.  
  165.   template <class T1, class T2>
  166.   inline bool operator<=(const pair<T1, T2>& x, const pair<T1, T2>& y)
  167.   { 
  168.     return !(y < x);
  169.   }
  170. #endif
  171.  
  172.   template <class T1, class T2>
  173.   inline pair<T1, T2> make_pair(const T1& x, const T2& y)
  174.   {
  175.     return pair<T1, T2>(x, y);
  176.   }
  177.  
  178. #ifndef _RWSTD_NO_NAMESPACE
  179. }
  180. #endif
  181.  
  182. #endif /*__STD_UTILITY__*/
  183. #ifndef __USING_STD_NAMES__
  184.   using namespace std;
  185. #endif
  186. #pragma option pop
  187. #endif /* __UTILITY_H */
  188.