xref: /llvm-project/libcxx/test/std/containers/test_compare.h (revision 5cc55fdb57c989b0987faaae7b667cd3459abae1)
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 #ifndef TEST_COMPARE_H
10 #define TEST_COMPARE_H
11 
12 template <class T>
13 struct test_equal_to
14 {
15     int data_;
test_equal_totest_equal_to16     explicit test_equal_to() : data_(0) {}
test_equal_totest_equal_to17     explicit test_equal_to(int data) : data_(data) {}
operatortest_equal_to18     bool operator()(const T& a, const T& b) const
19         { return a == b; }
20     friend bool operator==(const test_equal_to& a, const test_equal_to& b)
21         { return a.data_ == b.data_; }
22 };
23 
24 template <class T>
25 struct test_less
26 {
27     int data_;
test_lesstest_less28     explicit test_less() : data_(0) {}
test_lesstest_less29     explicit test_less(int data) : data_(data) {}
operatortest_less30     bool operator()(const T& a, const T& b) const
31         { return a < b; }
32     friend bool operator==(const test_less& a, const test_less& b)
33         { return a.data_ == b.data_; }
34 };
35 
36 #endif // TEST_COMPARE_H
37