]>
Commit | Line | Data |
---|---|---|
42526146 PE |
1 | // std::rel_ops implementation -*- C++ -*- |
2 | ||
83ffe9cd | 3 | // Copyright (C) 2001-2023 Free Software Foundation, Inc. |
42526146 PE |
4 | // |
5 | // This file is part of the GNU ISO C++ Library. This library is free | |
6 | // software; you can redistribute it and/or modify it under the | |
7 | // terms of the GNU General Public License as published by the | |
748086b7 | 8 | // Free Software Foundation; either version 3, or (at your option) |
42526146 PE |
9 | // any later version. |
10 | ||
11 | // This library is distributed in the hope that it will be useful, | |
12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | // GNU General Public License for more details. | |
15 | ||
748086b7 JJ |
16 | // Under Section 7 of GPL version 3, you are granted additional |
17 | // permissions described in the GCC Runtime Library Exception, version | |
18 | // 3.1, as published by the, 2009 Free Software Foundation. | |
42526146 | 19 | |
748086b7 JJ |
20 | // You should have received a copy of the GNU General Public License and |
21 | // a copy of the GCC Runtime Library Exception along with this program; | |
22 | // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see | |
23 | // <http://www.gnu.org/licenses/>. | |
42526146 | 24 | |
725dc051 BK |
25 | /* |
26 | * | |
27 | * Copyright (c) 1994 | |
28 | * Hewlett-Packard Company | |
29 | * | |
30 | * Permission to use, copy, modify, distribute and sell this software | |
31 | * and its documentation for any purpose is hereby granted without fee, | |
32 | * provided that the above copyright notice appear in all copies and | |
33 | * that both that copyright notice and this permission notice appear | |
34 | * in supporting documentation. Hewlett-Packard Company makes no | |
35 | * representations about the suitability of this software for any | |
36 | * purpose. It is provided "as is" without express or implied warranty. | |
37 | * | |
38 | * Copyright (c) 1996,1997 | |
39 | * Silicon Graphics | |
40 | * | |
41 | * Permission to use, copy, modify, distribute and sell this software | |
42 | * and its documentation for any purpose is hereby granted without fee, | |
43 | * provided that the above copyright notice appear in all copies and | |
44 | * that both that copyright notice and this permission notice appear | |
45 | * in supporting documentation. Silicon Graphics makes no | |
46 | * representations about the suitability of this software for any | |
47 | * purpose. It is provided "as is" without express or implied warranty. | |
48 | * | |
49 | */ | |
50 | ||
f910786b | 51 | /** @file bits/stl_relops.h |
729e3d3f | 52 | * This is an internal header file, included by other library headers. |
f910786b | 53 | * Do not attempt to use it directly. @headername{utility} |
ffe94f83 | 54 | * |
5b965dc4 JW |
55 | * This file is only included by `<utility>`, which is required by the |
56 | * standard to define namespace `rel_ops` and its contents. | |
729e3d3f PE |
57 | */ |
58 | ||
3d7c150e BK |
59 | #ifndef _STL_RELOPS_H |
60 | #define _STL_RELOPS_H 1 | |
725dc051 | 61 | |
12ffa228 BK |
62 | namespace std _GLIBCXX_VISIBILITY(default) |
63 | { | |
4a15d842 FD |
64 | _GLIBCXX_BEGIN_NAMESPACE_VERSION |
65 | ||
d53d7f6e PE |
66 | namespace rel_ops |
67 | { | |
f6592a9e PC |
68 | /** @namespace std::rel_ops |
69 | * @brief The generated relational operators are sequestered here. | |
5b965dc4 JW |
70 | * |
71 | * Libstdc++ headers must not use the contents of `rel_ops`. | |
72 | * User code should also avoid them, because unconstrained function | |
73 | * templates are too greedy and can easily cause ambiguities. | |
74 | * | |
75 | * C++20 default comparisons are a better solution. | |
f6592a9e | 76 | */ |
ed6814f7 | 77 | |
f6592a9e PC |
78 | /** |
79 | * @brief Defines @c != for arbitrary types, in terms of @c ==. | |
93c66bc6 BK |
80 | * @param __x A thing. |
81 | * @param __y Another thing. | |
82 | * @return __x != __y | |
f6592a9e PC |
83 | * |
84 | * This function uses @c == to determine its result. | |
85 | */ | |
86 | template <class _Tp> | |
87 | inline bool | |
88 | operator!=(const _Tp& __x, const _Tp& __y) | |
89 | { return !(__x == __y); } | |
ffe94f83 | 90 | |
f6592a9e PC |
91 | /** |
92 | * @brief Defines @c > for arbitrary types, in terms of @c <. | |
93c66bc6 BK |
93 | * @param __x A thing. |
94 | * @param __y Another thing. | |
95 | * @return __x > __y | |
f6592a9e PC |
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; } | |
725dc051 | 103 | |
f6592a9e PC |
104 | /** |
105 | * @brief Defines @c <= for arbitrary types, in terms of @c <. | |
93c66bc6 BK |
106 | * @param __x A thing. |
107 | * @param __y Another thing. | |
108 | * @return __x <= __y | |
f6592a9e PC |
109 | * |
110 | * This function uses @c < to determine its result. | |
111 | */ | |
112 | template <class _Tp> | |
113 | inline bool | |
114 | operator<=(const _Tp& __x, const _Tp& __y) | |
115 | { return !(__y < __x); } | |
725dc051 | 116 | |
f6592a9e PC |
117 | /** |
118 | * @brief Defines @c >= for arbitrary types, in terms of @c <. | |
93c66bc6 BK |
119 | * @param __x A thing. |
120 | * @param __y Another thing. | |
121 | * @return __x >= __y | |
f6592a9e PC |
122 | * |
123 | * This function uses @c < to determine its result. | |
124 | */ | |
125 | template <class _Tp> | |
126 | inline bool | |
127 | operator>=(const _Tp& __x, const _Tp& __y) | |
128 | { return !(__x < __y); } | |
d53d7f6e | 129 | } // namespace rel_ops |
3cbc7af0 | 130 | |
4a15d842 | 131 | _GLIBCXX_END_NAMESPACE_VERSION |
12ffa228 | 132 | } // namespace std |
725dc051 | 133 | |
3d7c150e | 134 | #endif /* _STL_RELOPS_H */ |