You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

134 line
4.5KB

  1. // std::rel_ops implementation -*- C++ -*-
  2. // Copyright (C) 2001-2020 Free Software Foundation, Inc.
  3. //
  4. // This file is part of the GNU ISO C++ Library. This library is free
  5. // software; you can redistribute it and/or modify it under the
  6. // terms of the GNU General Public License as published by the
  7. // Free Software Foundation; either version 3, or (at your option)
  8. // any later version.
  9. // This library is distributed in the hope that it will be useful,
  10. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. // GNU General Public License for more details.
  13. // Under Section 7 of GPL version 3, you are granted additional
  14. // permissions described in the GCC Runtime Library Exception, version
  15. // 3.1, as published by the, 2009 Free Software Foundation.
  16. // You should have received a copy of the GNU General Public License and
  17. // a copy of the GCC Runtime Library Exception along with this program;
  18. // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
  19. // <http://www.gnu.org/licenses/>.
  20. /*
  21. *
  22. * Copyright (c) 1994
  23. * Hewlett-Packard Company
  24. *
  25. * Permission to use, copy, modify, distribute and sell this software
  26. * and its documentation for any purpose is hereby granted without fee,
  27. * provided that the above copyright notice appear in all copies and
  28. * that both that copyright notice and this permission notice appear
  29. * in supporting documentation. Hewlett-Packard Company makes no
  30. * representations about the suitability of this software for any
  31. * purpose. It is provided "as is" without express or implied warranty.
  32. *
  33. * Copyright (c) 1996,1997
  34. * Silicon Graphics
  35. *
  36. * Permission to use, copy, modify, distribute and sell this software
  37. * and its documentation for any purpose is hereby granted without fee,
  38. * provided that the above copyright notice appear in all copies and
  39. * that both that copyright notice and this permission notice appear
  40. * in supporting documentation. Silicon Graphics makes no
  41. * representations about the suitability of this software for any
  42. * purpose. It is provided "as is" without express or implied warranty.
  43. *
  44. */
  45. /** @file bits/stl_relops.h
  46. * This is an internal header file, included by other library headers.
  47. * Do not attempt to use it directly. @headername{utility}
  48. *
  49. * Inclusion of this file has been removed from
  50. * all of the other STL headers for safety reasons, except std_utility.h.
  51. * For more information, see the thread of about twenty messages starting
  52. * with http://gcc.gnu.org/ml/libstdc++/2001-01/msg00223.html, or
  53. * http://gcc.gnu.org/onlinedocs/libstdc++/faq.html#faq.ambiguous_overloads
  54. *
  55. * Short summary: the rel_ops operators should be avoided for the present.
  56. */
  57. #ifndef _STL_RELOPS_H
  58. #define _STL_RELOPS_H 1
  59. namespace std _GLIBCXX_VISIBILITY(default)
  60. {
  61. _GLIBCXX_BEGIN_NAMESPACE_VERSION
  62. namespace rel_ops
  63. {
  64. /** @namespace std::rel_ops
  65. * @brief The generated relational operators are sequestered here.
  66. */
  67. /**
  68. * @brief Defines @c != for arbitrary types, in terms of @c ==.
  69. * @param __x A thing.
  70. * @param __y Another thing.
  71. * @return __x != __y
  72. *
  73. * This function uses @c == to determine its result.
  74. */
  75. template <class _Tp>
  76. inline bool
  77. operator!=(const _Tp& __x, const _Tp& __y)
  78. { return !(__x == __y); }
  79. /**
  80. * @brief Defines @c > for arbitrary types, in terms of @c <.
  81. * @param __x A thing.
  82. * @param __y Another thing.
  83. * @return __x > __y
  84. *
  85. * This function uses @c < to determine its result.
  86. */
  87. template <class _Tp>
  88. inline bool
  89. operator>(const _Tp& __x, const _Tp& __y)
  90. { return __y < __x; }
  91. /**
  92. * @brief Defines @c <= for arbitrary types, in terms of @c <.
  93. * @param __x A thing.
  94. * @param __y Another thing.
  95. * @return __x <= __y
  96. *
  97. * This function uses @c < to determine its result.
  98. */
  99. template <class _Tp>
  100. inline bool
  101. operator<=(const _Tp& __x, const _Tp& __y)
  102. { return !(__y < __x); }
  103. /**
  104. * @brief Defines @c >= for arbitrary types, in terms of @c <.
  105. * @param __x A thing.
  106. * @param __y Another thing.
  107. * @return __x >= __y
  108. *
  109. * This function uses @c < to determine its result.
  110. */
  111. template <class _Tp>
  112. inline bool
  113. operator>=(const _Tp& __x, const _Tp& __y)
  114. { return !(__x < __y); }
  115. } // namespace rel_ops
  116. _GLIBCXX_END_NAMESPACE_VERSION
  117. } // namespace std
  118. #endif /* _STL_RELOPS_H */