ranges_includes.h 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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. _LIBCPP_PUSH_MACROS
  27. #include <__undef_macros>
  28. #if _LIBCPP_STD_VER >= 20
  29. _LIBCPP_BEGIN_NAMESPACE_STD
  30. namespace ranges {
  31. namespace __includes {
  32. struct __fn {
  33. template <input_iterator _Iter1,
  34. sentinel_for<_Iter1> _Sent1,
  35. input_iterator _Iter2,
  36. sentinel_for<_Iter2> _Sent2,
  37. class _Proj1 = identity,
  38. class _Proj2 = identity,
  39. indirect_strict_weak_order<projected<_Iter1, _Proj1>, projected<_Iter2, _Proj2>> _Comp = ranges::less>
  40. _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr bool operator()(
  41. _Iter1 __first1,
  42. _Sent1 __last1,
  43. _Iter2 __first2,
  44. _Sent2 __last2,
  45. _Comp __comp = {},
  46. _Proj1 __proj1 = {},
  47. _Proj2 __proj2 = {}) const {
  48. return std::__includes(
  49. std::move(__first1),
  50. std::move(__last1),
  51. std::move(__first2),
  52. std::move(__last2),
  53. std::move(__comp),
  54. std::move(__proj1),
  55. std::move(__proj2));
  56. }
  57. template <input_range _Range1,
  58. input_range _Range2,
  59. class _Proj1 = identity,
  60. class _Proj2 = identity,
  61. indirect_strict_weak_order<projected<iterator_t<_Range1>, _Proj1>, projected<iterator_t<_Range2>, _Proj2>>
  62. _Comp = ranges::less>
  63. _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr bool operator()(
  64. _Range1&& __range1, _Range2&& __range2, _Comp __comp = {}, _Proj1 __proj1 = {}, _Proj2 __proj2 = {}) const {
  65. return std::__includes(
  66. ranges::begin(__range1),
  67. ranges::end(__range1),
  68. ranges::begin(__range2),
  69. ranges::end(__range2),
  70. std::move(__comp),
  71. std::move(__proj1),
  72. std::move(__proj2));
  73. }
  74. };
  75. } // namespace __includes
  76. inline namespace __cpo {
  77. inline constexpr auto includes = __includes::__fn{};
  78. } // namespace __cpo
  79. } // namespace ranges
  80. _LIBCPP_END_NAMESPACE_STD
  81. #endif // _LIBCPP_STD_VER >= 20
  82. _LIBCPP_POP_MACROS
  83. #endif // _LIBCPP___ALGORITHM_RANGES_INCLUDES_H