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 _LIBCPP___ALGORITHM_COMP_H
10#define _LIBCPP___ALGORITHM_COMP_H
11
12#include <__config>
13#include <__type_traits/desugars_to.h>
14#include <__type_traits/is_generic_transparent_comparator.h>
15#include <__type_traits/is_integral.h>
16#include <__type_traits/remove_cvref.h>
17
18#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
19# pragma GCC system_header
20#endif
21
22_LIBCPP_BEGIN_NAMESPACE_STD
23
24struct __equal_to {
25 template <class _T1, class _T2>
26 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 bool operator()(const _T1& __x, const _T2& __y) const {
27 return __x == __y;
28 }
29};
30
31template <class _Tp, class _Up>
32inline const bool __desugars_to_v<__equal_tag, __equal_to, _Tp, _Up> = true;
33
34// The definition is required because __less is part of the ABI, but it's empty
35// because all comparisons should be transparent.
36template <class _T1 = void, class _T2 = _T1>
37struct __less {};
38
39template <>
40struct __less<void, void> {
41 template <class _Tp, class _Up>
42 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 bool operator()(const _Tp& __lhs, const _Up& __rhs) const {
43 return __lhs < __rhs;
44 }
45};
46
47template <class _Tp>
48inline const bool __desugars_to_v<__less_tag, __less<>, _Tp, _Tp> = true;
49
50template <class _Tp>
51inline const bool __desugars_to_v<__totally_ordered_less_tag, __less<>, _Tp, _Tp> =
52 is_integral<__remove_cvref_t<_Tp> >::value;
53
54template <>
55inline const bool __is_generic_transparent_comparator_v<__less<> > = true;
56
57_LIBCPP_END_NAMESPACE_STD
58
59#endif // _LIBCPP___ALGORITHM_COMP_H
60