Debian Codegraph @

libcxx/test/std/utilities/utility/operators/rel_ops.pass.cpp

raw
1 //===----------------------------------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8
9 // test rel_ops
10
11 // ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DISABLE_DEPRECATION_WARNINGS
12
13 #include <utility>
14 #include <cassert>
15
16 #include "test_macros.h"
17
18 struct A
19 {
20 int data_;
21
22 explicit A(int data = -1) : data_(data) {}
23 };
24
25 inline
26 bool
27 operator == (const A& x, const A& y)
28 {
29 return x.data_ == y.data_;
30 }
31
32 inline
33 bool
34 operator < (const A& x, const A& y)
35 {
36 return x.data_ < y.data_;
37 }
38
39 int main(int, char**)
40 {
41 using namespace std::rel_ops;
42 A a1(1);
43 A a2(2);
44 assert(a1 == a1);
45 assert(a1 != a2);
46 assert(a1 < a2);
47 assert(a2 > a1);
48 assert(a1 <= a1);
49 assert(a1 <= a2);
50 assert(a2 >= a2);
51 assert(a2 >= a1);
52
53 return 0;
54 }