libstdc++
stl_relops.h
Go to the documentation of this file.
00001 // std::rel_ops implementation -*- C++ -*-
00002 
00003 // Copyright (C) 2001, 2002, 2004, 2005, 2008, 2010, 2011
00004 // Free Software Foundation, Inc.
00005 //
00006 // This file is part of the GNU ISO C++ Library.  This library is free
00007 // software; you can redistribute it and/or modify it under the
00008 // terms of the GNU General Public License as published by the
00009 // Free Software Foundation; either version 3, or (at your option)
00010 // any later version.
00011 
00012 // This library is distributed in the hope that it will be useful,
00013 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00014 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015 // GNU General Public License for more details.
00016 
00017 // Under Section 7 of GPL version 3, you are granted additional
00018 // permissions described in the GCC Runtime Library Exception, version
00019 // 3.1, as published by the, 2009 Free Software Foundation.
00020 
00021 // You should have received a copy of the GNU General Public License and
00022 // a copy of the GCC Runtime Library Exception along with this program;
00023 // see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
00024 // <http://www.gnu.org/licenses/>.
00025 
00026 /*
00027  *
00028  * Copyright (c) 1994
00029  * Hewlett-Packard Company
00030  *
00031  * Permission to use, copy, modify, distribute and sell this software
00032  * and its documentation for any purpose is hereby granted without fee,
00033  * provided that the above copyright notice appear in all copies and
00034  * that both that copyright notice and this permission notice appear
00035  * in supporting documentation.  Hewlett-Packard Company makes no
00036  * representations about the suitability of this software for any
00037  * purpose.  It is provided "as is" without express or implied warranty.
00038  *
00039  * Copyright (c) 1996,1997
00040  * Silicon Graphics
00041  *
00042  * Permission to use, copy, modify, distribute and sell this software
00043  * and its documentation for any purpose is hereby granted without fee,
00044  * provided that the above copyright notice appear in all copies and
00045  * that both that copyright notice and this permission notice appear
00046  * in supporting documentation.  Silicon Graphics makes no
00047  * representations about the suitability of this software for any
00048  * purpose.  It is provided "as is" without express or implied warranty.
00049  *
00050  */
00051 
00052 /** @file bits/stl_relops.h
00053  *  This is an internal header file, included by other library headers.
00054  *  Do not attempt to use it directly. @headername{utility}
00055  *
00056  *  Inclusion of this file has been removed from
00057  *  all of the other STL headers for safety reasons, except std_utility.h.
00058  *  For more information, see the thread of about twenty messages starting
00059  *  with http://gcc.gnu.org/ml/libstdc++/2001-01/msg00223.html, or
00060  *  http://gcc.gnu.org/onlinedocs/libstdc++/faq.html#faq.ambiguous_overloads
00061  *
00062  *  Short summary: the rel_ops operators should be avoided for the present.
00063  */
00064 
00065 #ifndef _STL_RELOPS_H
00066 #define _STL_RELOPS_H 1
00067 
00068 namespace std _GLIBCXX_VISIBILITY(default)
00069 {
00070   namespace rel_ops
00071   {
00072   _GLIBCXX_BEGIN_NAMESPACE_VERSION
00073 
00074     /** @namespace std::rel_ops
00075      *  @brief  The generated relational operators are sequestered here.
00076      */
00077 
00078     /**
00079      *  @brief Defines @c != for arbitrary types, in terms of @c ==.
00080      *  @param  x  A thing.
00081      *  @param  y  Another thing.
00082      *  @return   x != y
00083      *
00084      *  This function uses @c == to determine its result.
00085      */
00086     template <class _Tp>
00087       inline bool
00088       operator!=(const _Tp& __x, const _Tp& __y)
00089       { return !(__x == __y); }
00090 
00091     /**
00092      *  @brief Defines @c > for arbitrary types, in terms of @c <.
00093      *  @param  x  A thing.
00094      *  @param  y  Another thing.
00095      *  @return   x > y
00096      *
00097      *  This function uses @c < to determine its result.
00098      */
00099     template <class _Tp>
00100       inline bool
00101       operator>(const _Tp& __x, const _Tp& __y)
00102       { return __y < __x; }
00103 
00104     /**
00105      *  @brief Defines @c <= for arbitrary types, in terms of @c <.
00106      *  @param  x  A thing.
00107      *  @param  y  Another thing.
00108      *  @return   x <= y
00109      *
00110      *  This function uses @c < to determine its result.
00111      */
00112     template <class _Tp>
00113       inline bool
00114       operator<=(const _Tp& __x, const _Tp& __y)
00115       { return !(__y < __x); }
00116 
00117     /**
00118      *  @brief Defines @c >= for arbitrary types, in terms of @c <.
00119      *  @param  x  A thing.
00120      *  @param  y  Another thing.
00121      *  @return   x >= y
00122      *
00123      *  This function uses @c < to determine its result.
00124      */
00125     template <class _Tp>
00126       inline bool
00127       operator>=(const _Tp& __x, const _Tp& __y)
00128       { return !(__x < __y); }
00129 
00130   _GLIBCXX_END_NAMESPACE_VERSION
00131   } // namespace rel_ops
00132 
00133 } // namespace std
00134 
00135 #endif /* _STL_RELOPS_H */