]>
git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/20_util/function_objects/comparisons_pointer.cc
1 // Copyright (C) 2018-2019 Free Software Foundation, Inc.
3 // This file is part of the GNU ISO C++ Library. This library is free
4 // software; you can redistribute it and/or modify it under the
5 // terms of the GNU General Public License as published by the
6 // Free Software Foundation; either version 3, or (at your option)
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.
14 // You should have received a copy of the GNU General Public License along
15 // with this library; see the file COPYING3. If not see
16 // <http://www.gnu.org/licenses/>.
22 #include <testsuite_hooks.h>
31 std::greater
<int*> gt
;
34 ss
<< gt(p
, b
) << ' ' << gt(b
, p
) << ' ' << (!gt(p
, b
) && !gt(b
, p
));
40 #if __cplusplus >= 201402L
41 static_assert( gt(a
+1, a
), "constexpr greater<int*>" );
42 static_assert( !gt(a
, a
+1), "constexpr greater<int*>" );
49 ss
<< gt2(p2
, b
) << ' ' << gt2(b
, p2
) << ' ' << (!gt2(p2
, b
) && !gt2(b
, p2
));
54 static_assert( gt2(a
+1, a
), "constexpr greater<>" );
55 static_assert( !gt2(a
, a
+1), "constexpr greater<>" );
66 ss
<< lt(p
, b
) << ' ' << lt(b
, p
) << ' ' << (!lt(p
, b
) && !lt(b
, p
));
72 #if __cplusplus >= 201402L
73 static_assert( lt(a
, a
+1), "constexpr less<int*>" );
74 static_assert( !lt(a
+1, a
), "constexpr less<int*>" );
81 ss
<< lt2(p2
, b
) << ' ' << lt2(b
, p2
) << ' ' << (!lt2(p2
, b
) && !lt2(b
, p2
));
86 static_assert( lt2(a
, a
+1), "constexpr less<>" );
87 static_assert( !lt2(a
+1, a
), "constexpr less<>" );
95 std::greater_equal
<int*> ge
;
98 ss
<< !ge(p
, b
) << ' ' << !ge(b
, p
) << ' ' << (ge(p
, b
) && ge(b
, p
));
104 #if __cplusplus >= 201402L
105 static_assert( !ge(a
, a
+1), "constexpr greater_equal<int*>" );
106 static_assert( ge(a
, a
), "constexpr greater_equal<int*>" );
107 static_assert( ge(a
+1, a
), "constexpr greater_equal<int*>" );
113 std::greater_equal
<> ge2
;
114 ss
<< !ge2(p2
, b
) << ' ' << !ge2(b
, p2
) << ' ' << (ge2(p2
, b
) && ge2(b
, p2
));
119 static_assert( !ge2(a
, a
+1), "constexpr greater_equal<>" );
120 static_assert( ge2(a
, a
), "constexpr greater_equal<>" );
121 static_assert( ge2(a
+1, a
), "constexpr greater_equal<>" );
129 std::less_equal
<int*> le
;
131 std::stringstream ss
;
132 ss
<< !le(p
, b
) << ' ' << !le(b
, p
) << ' ' << (le(p
, b
) && le(b
, p
));
138 #if __cplusplus >= 201402L
139 static_assert( !le(a
+1, a
), "constexpr less_equal<int*>" );
140 static_assert( le(a
, a
), "constexpr less_equal<int*>" );
141 static_assert( le(a
, a
+1), "constexpr less_equal<int*>" );
147 std::less_equal
<> le2
;
148 ss
<< !le2(p2
, b
) << ' ' << !le2(b
, p2
) << ' ' << (le2(p2
, b
) && le2(b
, p2
));
153 static_assert( !le2(a
+1, a
), "constexpr less_equal<>" );
154 static_assert( le2(a
, a
), "constexpr less_equal<>" );
155 static_assert( le2(a
, a
+1), "constexpr less_equal<>" );
160 operator const X
*() const { return this; }
169 std::less
<const X
*> lt
;
171 std::stringstream ss
;
172 ss
<< lt(x
, p
) << ' ' << lt(p
, x
) << ' ' << (!lt(p
, x
) && !lt(x
, p
));
179 #if __cplusplus >= 201402L
180 static_assert( lt(y
, y
+1), "constexpr less<const X*>" );
181 static_assert( !lt(y
+1, y
), "constexpr less<const X*>" );
188 ss
<< lt2(x
, p2
) << ' ' << lt2(p2
, x
) << ' ' << (!lt2(x
, p2
) && !lt2(p2
, x
));
193 static_assert( lt2(y
, y
+1), "constexpr less<>" );
194 static_assert( !lt2(y
+1, y
), "constexpr less<>" );
199 bool operator>(int) { return true; }
200 bool operator<(int) { return false; }
201 bool operator>=(int) { return true; }
202 bool operator<=(int) { return false; }
204 bool operator>(Overloaded
, Overloaded
) { return false; }
205 bool operator<(Overloaded
, Overloaded
) { return false; }
206 bool operator>=(Overloaded
, Overloaded
) { return true; }
207 bool operator<=(Overloaded
, Overloaded
) { return true; }
212 #if __cplusplus >= 201402L
213 std::greater
<void> gt
;
215 std::greater_equal
<void> ge
;
216 std::less_equal
<void> le
;