xref: /freebsd-src/contrib/llvm-project/libcxx/include/__algorithm/comp.h (revision 0fca6ea1d4eea4c934cfff25ac9ee8ad6fe95583)
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*0fca6ea1SDimitry Andric #include <__type_traits/desugars_to.h>
14fe6060f1SDimitry Andric 
15fe6060f1SDimitry Andric #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
16fe6060f1SDimitry Andric #  pragma GCC system_header
17fe6060f1SDimitry Andric #endif
18fe6060f1SDimitry Andric 
19fe6060f1SDimitry Andric _LIBCPP_BEGIN_NAMESPACE_STD
20fe6060f1SDimitry Andric 
21bdd1243dSDimitry Andric struct __equal_to {
22bdd1243dSDimitry Andric   template <class _T1, class _T2>
23bdd1243dSDimitry Andric   _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 bool operator()(const _T1& __x, const _T2& __y) const {
24bdd1243dSDimitry Andric     return __x == __y;
25bdd1243dSDimitry Andric   }
26fe6060f1SDimitry Andric };
27fe6060f1SDimitry Andric 
285f757f3fSDimitry Andric template <class _Tp, class _Up>
29*0fca6ea1SDimitry Andric inline const bool __desugars_to_v<__equal_tag, __equal_to, _Tp, _Up> = true;
30fe6060f1SDimitry Andric 
3106c3fb27SDimitry Andric // The definition is required because __less is part of the ABI, but it's empty
3206c3fb27SDimitry Andric // because all comparisons should be transparent.
3306c3fb27SDimitry Andric template <class _T1 = void, class _T2 = _T1>
3406c3fb27SDimitry Andric struct __less {};
35fe6060f1SDimitry Andric 
3606c3fb27SDimitry Andric template <>
3706c3fb27SDimitry Andric struct __less<void, void> {
3806c3fb27SDimitry Andric   template <class _Tp, class _Up>
3906c3fb27SDimitry Andric   _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 bool operator()(const _Tp& __lhs, const _Up& __rhs) const {
4006c3fb27SDimitry Andric     return __lhs < __rhs;
4106c3fb27SDimitry Andric   }
42fe6060f1SDimitry Andric };
43fe6060f1SDimitry Andric 
44*0fca6ea1SDimitry Andric template <class _Tp>
45*0fca6ea1SDimitry Andric inline const bool __desugars_to_v<__less_tag, __less<>, _Tp, _Tp> = true;
46*0fca6ea1SDimitry Andric 
47fe6060f1SDimitry Andric _LIBCPP_END_NAMESPACE_STD
48fe6060f1SDimitry Andric 
49fe6060f1SDimitry Andric #endif // _LIBCPP___ALGORITHM_COMP_H
50