aboutsummaryrefslogtreecommitdiff
path: root/libcxx/test/std/containers/test_compare.h
blob: 070f15869a4a39cbeffc4547debfd5b9b6e7e387 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#ifndef TEST_COMPARE_H
#define TEST_COMPARE_H

#include "test_macros.h"

template <class T>
struct test_equal_to {
  int data_;
  TEST_CONSTEXPR explicit test_equal_to() : data_(0) {}
  TEST_CONSTEXPR explicit test_equal_to(int data) : data_(data) {}
  TEST_CONSTEXPR bool operator()(const T& a, const T& b) const { return a == b; }
  TEST_CONSTEXPR friend bool operator==(const test_equal_to& a, const test_equal_to& b) { return a.data_ == b.data_; }
};

template <class T>
struct test_less {
  int data_;
  TEST_CONSTEXPR explicit test_less() : data_(0) {}
  TEST_CONSTEXPR explicit test_less(int data) : data_(data) {}
  TEST_CONSTEXPR bool operator()(const T& a, const T& b) const { return a < b; }
  TEST_CONSTEXPR friend bool operator==(const test_less& a, const test_less& b) { return a.data_ == b.data_; }
};

#endif // TEST_COMPARE_H