• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #include <utility>
12 #include <cassert>
13 
14 #include "test_macros.h"
15 
16 struct A
17 {
18     int data_;
19 
AA20     explicit A(int data = -1) : data_(data) {}
21 };
22 
23 inline
24 bool
operator ==(const A & x,const A & y)25 operator == (const A& x, const A& y)
26 {
27     return x.data_ == y.data_;
28 }
29 
30 inline
31 bool
operator <(const A & x,const A & y)32 operator < (const A& x, const A& y)
33 {
34     return x.data_ < y.data_;
35 }
36 
main(int,char **)37 int main(int, char**)
38 {
39     using namespace std::rel_ops;
40     A a1(1);
41     A a2(2);
42     assert(a1 == a1);
43     assert(a1 != a2);
44     assert(a1 < a2);
45     assert(a2 > a1);
46     assert(a1 <= a1);
47     assert(a1 <= a2);
48     assert(a2 >= a2);
49     assert(a2 >= a1);
50 
51   return 0;
52 }
53