comp.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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. #ifndef _LIBCPP___ALGORITHM_COMP_H
  9. #define _LIBCPP___ALGORITHM_COMP_H
  10. #include <__config>
  11. #include <__type_traits/integral_constant.h>
  12. #include <__type_traits/operation_traits.h>
  13. #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
  14. # pragma GCC system_header
  15. #endif
  16. _LIBCPP_BEGIN_NAMESPACE_STD
  17. struct __equal_to {
  18. template <class _T1, class _T2>
  19. _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 bool operator()(const _T1& __x, const _T2& __y) const {
  20. return __x == __y;
  21. }
  22. };
  23. template <class _Tp, class _Up>
  24. struct __desugars_to<__equal_tag, __equal_to, _Tp, _Up> : true_type {};
  25. // The definition is required because __less is part of the ABI, but it's empty
  26. // because all comparisons should be transparent.
  27. template <class _T1 = void, class _T2 = _T1>
  28. struct __less {};
  29. template <>
  30. struct __less<void, void> {
  31. template <class _Tp, class _Up>
  32. _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 bool operator()(const _Tp& __lhs, const _Up& __rhs) const {
  33. return __lhs < __rhs;
  34. }
  35. };
  36. _LIBCPP_END_NAMESPACE_STD
  37. #endif // _LIBCPP___ALGORITHM_COMP_H