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 14 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 15 # pragma GCC system_header 16 # pragma clang include_instead(<algorithm>) 17 #endif 18 19 _LIBCPP_BEGIN_NAMESPACE_STD 20 21 // I'd like to replace these with _VSTD::equal_to<void>, but can't because: 22 // * That only works with C++14 and later, and 23 // * We haven't included <functional> here. 24 template <class _T1, class _T2 = _T1> 25 struct __equal_to 26 { 27 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 bool operator()(const _T1& __x, const _T1& __y) const {return __x == __y;} 28 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 bool operator()(const _T1& __x, const _T2& __y) const {return __x == __y;} 29 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 bool operator()(const _T2& __x, const _T1& __y) const {return __x == __y;} 30 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 bool operator()(const _T2& __x, const _T2& __y) const {return __x == __y;} 31 }; 32 33 template <class _T1> 34 struct __equal_to<_T1, _T1> 35 { 36 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 37 bool operator()(const _T1& __x, const _T1& __y) const {return __x == __y;} 38 }; 39 40 template <class _T1> 41 struct __equal_to<const _T1, _T1> 42 { 43 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 44 bool operator()(const _T1& __x, const _T1& __y) const {return __x == __y;} 45 }; 46 47 template <class _T1> 48 struct __equal_to<_T1, const _T1> 49 { 50 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 51 bool operator()(const _T1& __x, const _T1& __y) const {return __x == __y;} 52 }; 53 54 template <class _T1, class _T2 = _T1> 55 struct __less 56 { 57 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 58 bool operator()(const _T1& __x, const _T1& __y) const {return __x < __y;} 59 60 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 61 bool operator()(const _T1& __x, const _T2& __y) const {return __x < __y;} 62 63 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 64 bool operator()(const _T2& __x, const _T1& __y) const {return __x < __y;} 65 66 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 67 bool operator()(const _T2& __x, const _T2& __y) const {return __x < __y;} 68 }; 69 70 template <class _T1> 71 struct __less<_T1, _T1> 72 { 73 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 74 bool operator()(const _T1& __x, const _T1& __y) const {return __x < __y;} 75 }; 76 77 template <class _T1> 78 struct __less<const _T1, _T1> 79 { 80 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 81 bool operator()(const _T1& __x, const _T1& __y) const {return __x < __y;} 82 }; 83 84 template <class _T1> 85 struct __less<_T1, const _T1> 86 { 87 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 88 bool operator()(const _T1& __x, const _T1& __y) const {return __x < __y;} 89 }; 90 91 _LIBCPP_END_NAMESPACE_STD 92 93 #endif // _LIBCPP___ALGORITHM_COMP_H 94