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