brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.0 KiB · db0c7a6 Raw
55 lines · cpp
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-exception6//7//===----------------------------------------------------------------------===//8 9// test rel_ops10 11// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DISABLE_DEPRECATION_WARNINGS12 13#include <utility>14#include <cassert>15 16#include "test_macros.h"17 18struct A19{20    int data_;21 22    explicit A(int data = -1) : data_(data) {}23};24 25inline26bool27operator == (const A& x, const A& y)28{29    return x.data_ == y.data_;30}31 32inline33bool34operator < (const A& x, const A& y)35{36    return x.data_ < y.data_;37}38 39int 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}55