xref: /freebsd-src/contrib/llvm-project/libcxx/include/__algorithm/comp.h (revision 06c3fb2749bda94cb5201f81ffdb8fa6c3161b2e)
1fe6060f1SDimitry Andric //===----------------------------------------------------------------------===//
2fe6060f1SDimitry Andric //
3fe6060f1SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4fe6060f1SDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
5fe6060f1SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6fe6060f1SDimitry Andric //
7fe6060f1SDimitry Andric //===----------------------------------------------------------------------===//
8fe6060f1SDimitry Andric 
9fe6060f1SDimitry Andric #ifndef _LIBCPP___ALGORITHM_COMP_H
10fe6060f1SDimitry Andric #define _LIBCPP___ALGORITHM_COMP_H
11fe6060f1SDimitry Andric 
12fe6060f1SDimitry Andric #include <__config>
13*06c3fb27SDimitry Andric #include <__type_traits/integral_constant.h>
14*06c3fb27SDimitry Andric #include <__type_traits/predicate_traits.h>
15fe6060f1SDimitry Andric 
16fe6060f1SDimitry Andric #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
17fe6060f1SDimitry Andric #  pragma GCC system_header
18fe6060f1SDimitry Andric #endif
19fe6060f1SDimitry Andric 
20fe6060f1SDimitry Andric _LIBCPP_BEGIN_NAMESPACE_STD
21fe6060f1SDimitry Andric 
22bdd1243dSDimitry Andric struct __equal_to {
23bdd1243dSDimitry Andric   template <class _T1, class _T2>
24bdd1243dSDimitry Andric   _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 bool operator()(const _T1& __x, const _T2& __y) const {
25bdd1243dSDimitry Andric     return __x == __y;
26bdd1243dSDimitry Andric   }
27fe6060f1SDimitry Andric };
28fe6060f1SDimitry Andric 
29*06c3fb27SDimitry Andric template <class _Lhs, class _Rhs>
30*06c3fb27SDimitry Andric struct __is_trivial_equality_predicate<__equal_to, _Lhs, _Rhs> : true_type {};
31fe6060f1SDimitry Andric 
32*06c3fb27SDimitry Andric // The definition is required because __less is part of the ABI, but it's empty
33*06c3fb27SDimitry Andric // because all comparisons should be transparent.
34*06c3fb27SDimitry Andric template <class _T1 = void, class _T2 = _T1>
35*06c3fb27SDimitry Andric struct __less {};
36fe6060f1SDimitry Andric 
37*06c3fb27SDimitry Andric template <>
38*06c3fb27SDimitry Andric struct __less<void, void> {
39*06c3fb27SDimitry Andric   template <class _Tp, class _Up>
40*06c3fb27SDimitry Andric   _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 bool operator()(const _Tp& __lhs, const _Up& __rhs) const {
41*06c3fb27SDimitry Andric     return __lhs < __rhs;
42*06c3fb27SDimitry Andric   }
43fe6060f1SDimitry Andric };
44fe6060f1SDimitry Andric 
45fe6060f1SDimitry Andric _LIBCPP_END_NAMESPACE_STD
46fe6060f1SDimitry Andric 
47fe6060f1SDimitry Andric #endif // _LIBCPP___ALGORITHM_COMP_H
48