home *** CD-ROM | disk | FTP | other *** search
/ PC Format (South-Africa) 2001 May / PCFMay2001.iso / Xenon / C++ / FreeCommandLineTools.exe / Include / utility.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-01-31  |  4.8 KB  |  178 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.  * Copyright (c) 1994-1999 Rogue Wave Software, Inc.  All Rights Reserved.
  29.  *
  30.  * This computer software is owned by Rogue Wave Software, Inc. and is
  31.  * protected by U.S. copyright laws and other laws and by international
  32.  * treaties.  This computer software is furnished by Rogue Wave Software,
  33.  * Inc. pursuant to a written license agreement and may be used, copied,
  34.  * transmitted, and stored only in accordance with the terms of such
  35.  * license and with the inclusion of the above copyright notice.  This
  36.  * computer software or any other copies thereof may not be provided or
  37.  * otherwise made available to any other person.
  38.  *
  39.  * U.S. Government Restricted Rights.  This computer software is provided
  40.  * with Restricted Rights.  Use, duplication, or disclosure by the
  41.  * Government is subject to restrictions as set forth in subparagraph (c)
  42.  * (1) (ii) of The Rights in Technical Data and Computer Software clause
  43.  * at DFARS 252.227-7013 or subparagraphs (c) (1) and (2) of the
  44.  * Commercial Computer Software รป Restricted Rights at 48 CFR 52.227-19,
  45.  * as applicable.  Manufacturer is Rogue Wave Software, Inc., 5500
  46.  * Flatiron Parkway, Boulder, Colorado 80301 USA.
  47.  *
  48.  **************************************************************************/
  49.  
  50. #include <stdcomp.h>
  51.  
  52. #ifndef _RWSTD_NO_NAMESPACE
  53. namespace std {
  54. #endif
  55.  
  56. #ifndef _RWSTD_NO_NAMESPACE
  57.   namespace rel_ops {
  58. #endif
  59.  
  60. //
  61. // Operators
  62. //
  63.  
  64.     template <class T>
  65.     inline bool operator!=(const T& x, const T& y)
  66.     {
  67.       return !(x == y);
  68.     }
  69.  
  70.     template <class T>
  71.     inline bool operator>(const T& x, const T& y)
  72.     {
  73.       return y < x;
  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 !(x < y);
  86.     }
  87.  
  88. #ifndef _RWSTD_NO_NAMESPACE
  89.   } /* End of namespace rel_ops */
  90. #endif
  91.  
  92. //
  93. // Pairs.
  94. //
  95.  
  96.   template <class T1, class T2>
  97.   struct pair
  98.   {
  99.     typedef T1 first_type;
  100.     typedef T2 second_type;
  101.  
  102.     T1 first;
  103.     T2 second;
  104.     pair (const T1& a, const T2& b) : first(a), second(b) {}
  105.     pair () 
  106. #ifndef _RWSTD_NO_BUILT_IN_CTOR
  107.       : first(T1()), second(T2()) 
  108. #endif
  109.     { ; }
  110.  
  111.     pair(const pair& p) 
  112.       : first(p.first), second(p.second)
  113.     { ; }
  114. #ifndef _RWSTD_NO_MEMBER_TEMPLATES
  115.     template <class U, class V> pair(const pair<U,V>& p) 
  116.       : first(p.first), second(p.second)
  117.     { ; }
  118. #endif
  119.  
  120.   };
  121.  
  122.   template <class T1, class T2>
  123.   inline bool operator==(const pair<T1, T2>& x, const pair<T1, T2>& y)
  124.   { 
  125.     return x.first == y.first && x.second == y.second; 
  126.   }
  127.  
  128.   template <class T1, class T2>
  129.   inline bool operator<(const pair<T1, T2>& x, const pair<T1, T2>& y)
  130.   { 
  131.     return x.first < y.first || (!(y.first < x.first) && x.second < y.second); 
  132.   }
  133.  
  134. #ifndef _RWSTD_NO_NAMESPACE
  135.   template <class T1, class T2>
  136.   inline bool operator!=(const pair<T1, T2>& x, const pair<T1, T2>& y)
  137.   { 
  138.     return !(x == y);
  139.   }
  140.  
  141.   template <class T1, class T2>
  142.   inline bool operator>(const pair<T1, T2>& x, const pair<T1, T2>& y)
  143.   { 
  144.     return y < x;
  145.   }
  146.  
  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. #endif
  159.  
  160.   template <class T1, class T2>
  161.   inline pair<T1, T2> make_pair(const T1& x, const T2& y)
  162.   {
  163.     return pair<T1, T2>(x, y);
  164.   }
  165.  
  166. #ifndef _RWSTD_NO_NAMESPACE
  167. }
  168. #endif
  169.  
  170. #endif /*__STD_UTILITY__*/
  171.  
  172. #ifndef __USING_STD_NAMES__
  173.   using namespace std;
  174. #endif
  175.  
  176. #pragma option pop
  177. #endif /* __UTILITY_H */
  178.