ranges_includes.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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_RANGES_INCLUDES_H
  9. #define _LIBCPP___ALGORITHM_RANGES_INCLUDES_H
  10. #include <__algorithm/includes.h>
  11. #include <__algorithm/make_projected.h>
  12. #include <__config>
  13. #include <__functional/identity.h>
  14. #include <__functional/invoke.h>
  15. #include <__functional/ranges_operations.h>
  16. #include <__iterator/concepts.h>
  17. #include <__iterator/iterator_traits.h>
  18. #include <__iterator/projected.h>
  19. #include <__ranges/access.h>
  20. #include <__ranges/concepts.h>
  21. #include <__utility/forward.h>
  22. #include <__utility/move.h>
  23. #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
  24. # pragma GCC system_header
  25. #endif
  26. #if _LIBCPP_STD_VER >= 20
  27. _LIBCPP_BEGIN_NAMESPACE_STD
  28. namespace ranges {
  29. namespace __includes {
  30. struct __fn {
  31. template <input_iterator _Iter1,
  32. sentinel_for<_Iter1> _Sent1,
  33. input_iterator _Iter2,
  34. sentinel_for<_Iter2> _Sent2,
  35. class _Proj1 = identity,
  36. class _Proj2 = identity,
  37. indirect_strict_weak_order<projected<_Iter1, _Proj1>, projected<_Iter2, _Proj2>> _Comp = ranges::less>
  38. _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr bool operator()(
  39. _Iter1 __first1,
  40. _Sent1 __last1,
  41. _Iter2 __first2,
  42. _Sent2 __last2,
  43. _Comp __comp = {},
  44. _Proj1 __proj1 = {},
  45. _Proj2 __proj2 = {}) const {
  46. return std::__includes(
  47. std::move(__first1),
  48. std::move(__last1),
  49. std::move(__first2),
  50. std::move(__last2),
  51. std::move(__comp),
  52. std::move(__proj1),
  53. std::move(__proj2));
  54. }
  55. template <input_range _Range1,
  56. input_range _Range2,
  57. class _Proj1 = identity,
  58. class _Proj2 = identity,
  59. indirect_strict_weak_order<projected<iterator_t<_Range1>, _Proj1>, projected<iterator_t<_Range2>, _Proj2>>
  60. _Comp = ranges::less>
  61. _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr bool operator()(
  62. _Range1&& __range1, _Range2&& __range2, _Comp __comp = {}, _Proj1 __proj1 = {}, _Proj2 __proj2 = {}) const {
  63. return std::__includes(
  64. ranges::begin(__range1),
  65. ranges::end(__range1),
  66. ranges::begin(__range2),
  67. ranges::end(__range2),
  68. std::move(__comp),
  69. std::move(__proj1),
  70. std::move(__proj2));
  71. }
  72. };
  73. } // namespace __includes
  74. inline namespace __cpo {
  75. inline constexpr auto includes = __includes::__fn{};
  76. } // namespace __cpo
  77. } // namespace ranges
  78. _LIBCPP_END_NAMESPACE_STD
  79. #endif // _LIBCPP_STD_VER >= 20
  80. #endif // _LIBCPP___ALGORITHM_RANGES_INCLUDES_H