blob: 32d831d40f4a4b646dac567a296d61ab4075bd64 [file] [log] [blame]
Marshall Clow354d39c2014-01-16 16:58:45 +00001//===----------------------------------------------------------------------===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is dual licensed under the MIT and the University of Illinois Open
6// Source Licenses. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
Howard Hinnant3e519522010-05-11 19:42:16 +000010#ifndef TEST_COMPARE_H
11#define TEST_COMPARE_H
12
13#include <cstddef>
14#include <type_traits>
15#include <cstdlib>
16#include <new>
17#include <climits>
18
19template <class C>
20class test_compare
21 : private C
22{
23 int data_;
24public:
25 explicit test_compare(int data = 0) : data_(data) {}
26
27 typename C::result_type
28 operator()(typename std::add_lvalue_reference<const typename C::first_argument_type>::type x,
29 typename std::add_lvalue_reference<const typename C::second_argument_type>::type y) const
30 {return C::operator()(x, y);}
31
32 bool operator==(const test_compare& c) const
33 {return data_ == c.data_;}
34};
35
Marshall Clow4999a5f2017-11-22 06:02:27 +000036
37template <class C>
38class non_const_compare
39{
Stephan T. Lavavejad9545e2018-04-12 23:56:22 +000040// operator() deliberately not marked as 'const'
41 bool operator()(const C& x, const C& y) { return x < y; }
Marshall Clow4999a5f2017-11-22 06:02:27 +000042};
43
44
Howard Hinnant8f2f7e72010-08-22 00:15:28 +000045#endif // TEST_COMPARE_H