zip_view.h 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516
  1. // -*- C++ -*-
  2. //===----------------------------------------------------------------------===//
  3. //
  4. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  5. // See https://llvm.org/LICENSE.txt for license information.
  6. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  7. //
  8. //===----------------------------------------------------------------------===//
  9. #ifndef _LIBCPP___RANGES_ZIP_VIEW_H
  10. #define _LIBCPP___RANGES_ZIP_VIEW_H
  11. #include <__config>
  12. #include <__algorithm/ranges_min.h>
  13. #include <__compare/three_way_comparable.h>
  14. #include <__concepts/convertible_to.h>
  15. #include <__concepts/equality_comparable.h>
  16. #include <__functional/invoke.h>
  17. #include <__functional/operations.h>
  18. #include <__iterator/concepts.h>
  19. #include <__iterator/incrementable_traits.h>
  20. #include <__iterator/iter_move.h>
  21. #include <__iterator/iter_swap.h>
  22. #include <__iterator/iterator_traits.h>
  23. #include <__ranges/access.h>
  24. #include <__ranges/all.h>
  25. #include <__ranges/concepts.h>
  26. #include <__ranges/empty_view.h>
  27. #include <__ranges/enable_borrowed_range.h>
  28. #include <__ranges/size.h>
  29. #include <__ranges/view_interface.h>
  30. #include <__type_traits/is_nothrow_move_constructible.h>
  31. #include <__type_traits/make_unsigned.h>
  32. #include <__utility/declval.h>
  33. #include <__utility/forward.h>
  34. #include <__utility/integer_sequence.h>
  35. #include <__utility/move.h>
  36. #include <tuple>
  37. #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
  38. # pragma GCC system_header
  39. #endif
  40. _LIBCPP_PUSH_MACROS
  41. #include <__undef_macros>
  42. _LIBCPP_BEGIN_NAMESPACE_STD
  43. #if _LIBCPP_STD_VER >= 23
  44. namespace ranges {
  45. template <class... _Ranges>
  46. concept __zip_is_common = (sizeof...(_Ranges) == 1 && (common_range<_Ranges> && ...)) ||
  47. (!(bidirectional_range<_Ranges> && ...) && (common_range<_Ranges> && ...)) ||
  48. ((random_access_range<_Ranges> && ...) && (sized_range<_Ranges> && ...));
  49. template <typename _Tp, typename _Up>
  50. auto __tuple_or_pair_test() -> pair<_Tp, _Up>;
  51. template <typename... _Types>
  52. requires(sizeof...(_Types) != 2)
  53. auto __tuple_or_pair_test() -> tuple<_Types...>;
  54. template <class... _Types>
  55. using __tuple_or_pair = decltype(__tuple_or_pair_test<_Types...>());
  56. template <class _Fun, class _Tuple>
  57. _LIBCPP_HIDE_FROM_ABI constexpr auto __tuple_transform(_Fun&& __f, _Tuple&& __tuple) {
  58. return std::apply(
  59. [&]<class... _Types>(_Types&&... __elements) {
  60. return __tuple_or_pair<invoke_result_t<_Fun&, _Types>...>(
  61. std::invoke(__f, std::forward<_Types>(__elements))...);
  62. },
  63. std::forward<_Tuple>(__tuple));
  64. }
  65. template <class _Fun, class _Tuple>
  66. _LIBCPP_HIDE_FROM_ABI constexpr void __tuple_for_each(_Fun&& __f, _Tuple&& __tuple) {
  67. std::apply(
  68. [&]<class... _Types>(_Types&&... __elements) {
  69. (static_cast<void>(std::invoke(__f, std::forward<_Types>(__elements))), ...);
  70. },
  71. std::forward<_Tuple>(__tuple));
  72. }
  73. template <class _Fun, class _Tuple1, class _Tuple2, size_t... _Indices>
  74. _LIBCPP_HIDE_FROM_ABI constexpr __tuple_or_pair<
  75. invoke_result_t<_Fun&, typename tuple_element<_Indices, remove_cvref_t<_Tuple1>>::type,
  76. typename tuple_element<_Indices, remove_cvref_t<_Tuple2>>::type>...>
  77. __tuple_zip_transform(_Fun&& __f, _Tuple1&& __tuple1, _Tuple2&& __tuple2, index_sequence<_Indices...>) {
  78. return {std::invoke(__f, std::get<_Indices>(std::forward<_Tuple1>(__tuple1)),
  79. std::get<_Indices>(std::forward<_Tuple2>(__tuple2)))...};
  80. }
  81. template <class _Fun, class _Tuple1, class _Tuple2>
  82. _LIBCPP_HIDE_FROM_ABI constexpr auto __tuple_zip_transform(_Fun&& __f, _Tuple1&& __tuple1, _Tuple2&& __tuple2) {
  83. return ranges::__tuple_zip_transform(__f, std::forward<_Tuple1>(__tuple1), std::forward<_Tuple2>(__tuple2),
  84. std::make_index_sequence<tuple_size<remove_cvref_t<_Tuple1>>::value>());
  85. }
  86. template <class _Fun, class _Tuple1, class _Tuple2, size_t... _Indices>
  87. _LIBCPP_HIDE_FROM_ABI constexpr void __tuple_zip_for_each(_Fun&& __f, _Tuple1&& __tuple1, _Tuple2&& __tuple2,
  88. index_sequence<_Indices...>) {
  89. (std::invoke(__f, std::get<_Indices>(std::forward<_Tuple1>(__tuple1)),
  90. std::get<_Indices>(std::forward<_Tuple2>(__tuple2))),
  91. ...);
  92. }
  93. template <class _Fun, class _Tuple1, class _Tuple2>
  94. _LIBCPP_HIDE_FROM_ABI constexpr auto __tuple_zip_for_each(_Fun&& __f, _Tuple1&& __tuple1, _Tuple2&& __tuple2) {
  95. return ranges::__tuple_zip_for_each(__f, std::forward<_Tuple1>(__tuple1), std::forward<_Tuple2>(__tuple2),
  96. std::make_index_sequence<tuple_size<remove_cvref_t<_Tuple1>>::value>());
  97. }
  98. template <class _Tuple1, class _Tuple2>
  99. _LIBCPP_HIDE_FROM_ABI constexpr bool __tuple_any_equals(const _Tuple1& __tuple1, const _Tuple2& __tuple2) {
  100. const auto __equals = ranges::__tuple_zip_transform(std::equal_to<>(), __tuple1, __tuple2);
  101. return std::apply([](auto... __bools) { return (__bools || ...); }, __equals);
  102. }
  103. // abs in cstdlib is not constexpr
  104. // TODO : remove __abs once P0533R9 is implemented.
  105. template <class _Tp>
  106. _LIBCPP_HIDE_FROM_ABI constexpr _Tp __abs(_Tp __t) {
  107. return __t < 0 ? -__t : __t;
  108. }
  109. template <input_range... _Views>
  110. requires(view<_Views> && ...) && (sizeof...(_Views) > 0)
  111. class zip_view : public view_interface<zip_view<_Views...>> {
  112. _LIBCPP_NO_UNIQUE_ADDRESS tuple<_Views...> __views_;
  113. template <bool>
  114. class __iterator;
  115. template <bool>
  116. class __sentinel;
  117. public:
  118. _LIBCPP_HIDE_FROM_ABI
  119. zip_view() = default;
  120. _LIBCPP_HIDE_FROM_ABI
  121. constexpr explicit zip_view(_Views... __views) : __views_(std::move(__views)...) {}
  122. _LIBCPP_HIDE_FROM_ABI
  123. constexpr auto begin()
  124. requires(!(__simple_view<_Views> && ...)) {
  125. return __iterator<false>(ranges::__tuple_transform(ranges::begin, __views_));
  126. }
  127. _LIBCPP_HIDE_FROM_ABI
  128. constexpr auto begin() const
  129. requires(range<const _Views> && ...) {
  130. return __iterator<true>(ranges::__tuple_transform(ranges::begin, __views_));
  131. }
  132. _LIBCPP_HIDE_FROM_ABI
  133. constexpr auto end()
  134. requires(!(__simple_view<_Views> && ...)) {
  135. if constexpr (!__zip_is_common<_Views...>) {
  136. return __sentinel<false>(ranges::__tuple_transform(ranges::end, __views_));
  137. } else if constexpr ((random_access_range<_Views> && ...)) {
  138. return begin() + iter_difference_t<__iterator<false>>(size());
  139. } else {
  140. return __iterator<false>(ranges::__tuple_transform(ranges::end, __views_));
  141. }
  142. }
  143. _LIBCPP_HIDE_FROM_ABI
  144. constexpr auto end() const
  145. requires(range<const _Views> && ...) {
  146. if constexpr (!__zip_is_common<const _Views...>) {
  147. return __sentinel<true>(ranges::__tuple_transform(ranges::end, __views_));
  148. } else if constexpr ((random_access_range<const _Views> && ...)) {
  149. return begin() + iter_difference_t<__iterator<true>>(size());
  150. } else {
  151. return __iterator<true>(ranges::__tuple_transform(ranges::end, __views_));
  152. }
  153. }
  154. _LIBCPP_HIDE_FROM_ABI
  155. constexpr auto size()
  156. requires(sized_range<_Views> && ...) {
  157. return std::apply(
  158. [](auto... __sizes) {
  159. using _CT = make_unsigned_t<common_type_t<decltype(__sizes)...>>;
  160. return ranges::min({_CT(__sizes)...});
  161. },
  162. ranges::__tuple_transform(ranges::size, __views_));
  163. }
  164. _LIBCPP_HIDE_FROM_ABI
  165. constexpr auto size() const
  166. requires(sized_range<const _Views> && ...) {
  167. return std::apply(
  168. [](auto... __sizes) {
  169. using _CT = make_unsigned_t<common_type_t<decltype(__sizes)...>>;
  170. return ranges::min({_CT(__sizes)...});
  171. },
  172. ranges::__tuple_transform(ranges::size, __views_));
  173. }
  174. };
  175. template <class... _Ranges>
  176. zip_view(_Ranges&&...) -> zip_view<views::all_t<_Ranges>...>;
  177. template <bool _Const, class... _Views>
  178. concept __zip_all_random_access = (random_access_range<__maybe_const<_Const, _Views>> && ...);
  179. template <bool _Const, class... _Views>
  180. concept __zip_all_bidirectional = (bidirectional_range<__maybe_const<_Const, _Views>> && ...);
  181. template <bool _Const, class... _Views>
  182. concept __zip_all_forward = (forward_range<__maybe_const<_Const, _Views>> && ...);
  183. template <bool _Const, class... _Views>
  184. consteval auto __get_zip_view_iterator_tag() {
  185. if constexpr (__zip_all_random_access<_Const, _Views...>) {
  186. return random_access_iterator_tag();
  187. } else if constexpr (__zip_all_bidirectional<_Const, _Views...>) {
  188. return bidirectional_iterator_tag();
  189. } else if constexpr (__zip_all_forward<_Const, _Views...>) {
  190. return forward_iterator_tag();
  191. } else {
  192. return input_iterator_tag();
  193. }
  194. }
  195. template <bool _Const, class... _Views>
  196. struct __zip_view_iterator_category_base {};
  197. template <bool _Const, class... _Views>
  198. requires __zip_all_forward<_Const, _Views...>
  199. struct __zip_view_iterator_category_base<_Const, _Views...> {
  200. using iterator_category = input_iterator_tag;
  201. };
  202. template <input_range... _Views>
  203. requires(view<_Views> && ...) && (sizeof...(_Views) > 0)
  204. template <bool _Const>
  205. class zip_view<_Views...>::__iterator : public __zip_view_iterator_category_base<_Const, _Views...> {
  206. __tuple_or_pair<iterator_t<__maybe_const<_Const, _Views>>...> __current_;
  207. _LIBCPP_HIDE_FROM_ABI
  208. constexpr explicit __iterator(__tuple_or_pair<iterator_t<__maybe_const<_Const, _Views>>...> __current)
  209. : __current_(std::move(__current)) {}
  210. template <bool>
  211. friend class zip_view<_Views...>::__iterator;
  212. template <bool>
  213. friend class zip_view<_Views...>::__sentinel;
  214. friend class zip_view<_Views...>;
  215. public:
  216. using iterator_concept = decltype(__get_zip_view_iterator_tag<_Const, _Views...>());
  217. using value_type = __tuple_or_pair<range_value_t<__maybe_const<_Const, _Views>>...>;
  218. using difference_type = common_type_t<range_difference_t<__maybe_const<_Const, _Views>>...>;
  219. _LIBCPP_HIDE_FROM_ABI
  220. __iterator() = default;
  221. _LIBCPP_HIDE_FROM_ABI
  222. constexpr __iterator(__iterator<!_Const> __i)
  223. requires _Const && (convertible_to<iterator_t<_Views>, iterator_t<__maybe_const<_Const, _Views>>> && ...)
  224. : __current_(std::move(__i.__current_)) {}
  225. _LIBCPP_HIDE_FROM_ABI
  226. constexpr auto operator*() const {
  227. return ranges::__tuple_transform([](auto& __i) -> decltype(auto) { return *__i; }, __current_);
  228. }
  229. _LIBCPP_HIDE_FROM_ABI
  230. constexpr __iterator& operator++() {
  231. ranges::__tuple_for_each([](auto& __i) { ++__i; }, __current_);
  232. return *this;
  233. }
  234. _LIBCPP_HIDE_FROM_ABI
  235. constexpr void operator++(int) { ++*this; }
  236. _LIBCPP_HIDE_FROM_ABI
  237. constexpr __iterator operator++(int)
  238. requires __zip_all_forward<_Const, _Views...> {
  239. auto __tmp = *this;
  240. ++*this;
  241. return __tmp;
  242. }
  243. _LIBCPP_HIDE_FROM_ABI
  244. constexpr __iterator& operator--()
  245. requires __zip_all_bidirectional<_Const, _Views...> {
  246. ranges::__tuple_for_each([](auto& __i) { --__i; }, __current_);
  247. return *this;
  248. }
  249. _LIBCPP_HIDE_FROM_ABI
  250. constexpr __iterator operator--(int)
  251. requires __zip_all_bidirectional<_Const, _Views...> {
  252. auto __tmp = *this;
  253. --*this;
  254. return __tmp;
  255. }
  256. _LIBCPP_HIDE_FROM_ABI
  257. constexpr __iterator& operator+=(difference_type __x)
  258. requires __zip_all_random_access<_Const, _Views...> {
  259. ranges::__tuple_for_each([&]<class _Iter>(_Iter& __i) { __i += iter_difference_t<_Iter>(__x); }, __current_);
  260. return *this;
  261. }
  262. _LIBCPP_HIDE_FROM_ABI
  263. constexpr __iterator& operator-=(difference_type __x)
  264. requires __zip_all_random_access<_Const, _Views...> {
  265. ranges::__tuple_for_each([&]<class _Iter>(_Iter& __i) { __i -= iter_difference_t<_Iter>(__x); }, __current_);
  266. return *this;
  267. }
  268. _LIBCPP_HIDE_FROM_ABI
  269. constexpr auto operator[](difference_type __n) const
  270. requires __zip_all_random_access<_Const, _Views...> {
  271. return ranges::__tuple_transform(
  272. [&]<class _Iter>(_Iter& __i) -> decltype(auto) { return __i[iter_difference_t<_Iter>(__n)]; }, __current_);
  273. }
  274. _LIBCPP_HIDE_FROM_ABI
  275. friend constexpr bool operator==(const __iterator& __x, const __iterator& __y)
  276. requires(equality_comparable<iterator_t<__maybe_const<_Const, _Views>>> && ...) {
  277. if constexpr (__zip_all_bidirectional<_Const, _Views...>) {
  278. return __x.__current_ == __y.__current_;
  279. } else {
  280. return ranges::__tuple_any_equals(__x.__current_, __y.__current_);
  281. }
  282. }
  283. _LIBCPP_HIDE_FROM_ABI
  284. friend constexpr bool operator<(const __iterator& __x, const __iterator& __y)
  285. requires __zip_all_random_access<_Const, _Views...> {
  286. return __x.__current_ < __y.__current_;
  287. }
  288. _LIBCPP_HIDE_FROM_ABI
  289. friend constexpr bool operator>(const __iterator& __x, const __iterator& __y)
  290. requires __zip_all_random_access<_Const, _Views...> {
  291. return __y < __x;
  292. }
  293. _LIBCPP_HIDE_FROM_ABI
  294. friend constexpr bool operator<=(const __iterator& __x, const __iterator& __y)
  295. requires __zip_all_random_access<_Const, _Views...> {
  296. return !(__y < __x);
  297. }
  298. _LIBCPP_HIDE_FROM_ABI
  299. friend constexpr bool operator>=(const __iterator& __x, const __iterator& __y)
  300. requires __zip_all_random_access<_Const, _Views...> {
  301. return !(__x < __y);
  302. }
  303. _LIBCPP_HIDE_FROM_ABI
  304. friend constexpr auto operator<=>(const __iterator& __x, const __iterator& __y)
  305. requires __zip_all_random_access<_Const, _Views...> &&
  306. (three_way_comparable<iterator_t<__maybe_const<_Const, _Views>>> && ...) {
  307. return __x.__current_ <=> __y.__current_;
  308. }
  309. _LIBCPP_HIDE_FROM_ABI
  310. friend constexpr __iterator operator+(const __iterator& __i, difference_type __n)
  311. requires __zip_all_random_access<_Const, _Views...> {
  312. auto __r = __i;
  313. __r += __n;
  314. return __r;
  315. }
  316. _LIBCPP_HIDE_FROM_ABI
  317. friend constexpr __iterator operator+(difference_type __n, const __iterator& __i)
  318. requires __zip_all_random_access<_Const, _Views...> {
  319. return __i + __n;
  320. }
  321. _LIBCPP_HIDE_FROM_ABI
  322. friend constexpr __iterator operator-(const __iterator& __i, difference_type __n)
  323. requires __zip_all_random_access<_Const, _Views...> {
  324. auto __r = __i;
  325. __r -= __n;
  326. return __r;
  327. }
  328. _LIBCPP_HIDE_FROM_ABI
  329. friend constexpr difference_type operator-(const __iterator& __x, const __iterator& __y)
  330. requires(sized_sentinel_for<iterator_t<__maybe_const<_Const, _Views>>, iterator_t<__maybe_const<_Const, _Views>>> &&
  331. ...) {
  332. const auto __diffs = ranges::__tuple_zip_transform(minus<>(), __x.__current_, __y.__current_);
  333. return std::apply(
  334. [](auto... __ds) {
  335. return ranges::min({difference_type(__ds)...},
  336. [](auto __a, auto __b) { return ranges::__abs(__a) < ranges::__abs(__b); });
  337. },
  338. __diffs);
  339. }
  340. _LIBCPP_HIDE_FROM_ABI
  341. friend constexpr auto iter_move(const __iterator& __i) noexcept(
  342. (noexcept(ranges::iter_move(std::declval<const iterator_t<__maybe_const<_Const, _Views>>&>())) && ...) &&
  343. (is_nothrow_move_constructible_v<range_rvalue_reference_t<__maybe_const<_Const, _Views>>> && ...)) {
  344. return ranges::__tuple_transform(ranges::iter_move, __i.__current_);
  345. }
  346. _LIBCPP_HIDE_FROM_ABI
  347. friend constexpr void iter_swap(const __iterator& __l, const __iterator& __r) noexcept(
  348. (noexcept(ranges::iter_swap(std::declval<const iterator_t<__maybe_const<_Const, _Views>>&>(),
  349. std::declval<const iterator_t<__maybe_const<_Const, _Views>>&>())) &&
  350. ...))
  351. requires(indirectly_swappable<iterator_t<__maybe_const<_Const, _Views>>> && ...) {
  352. ranges::__tuple_zip_for_each(ranges::iter_swap, __l.__current_, __r.__current_);
  353. }
  354. };
  355. template <input_range... _Views>
  356. requires(view<_Views> && ...) && (sizeof...(_Views) > 0)
  357. template <bool _Const>
  358. class zip_view<_Views...>::__sentinel {
  359. __tuple_or_pair<sentinel_t<__maybe_const<_Const, _Views>>...> __end_;
  360. _LIBCPP_HIDE_FROM_ABI
  361. constexpr explicit __sentinel(__tuple_or_pair<sentinel_t<__maybe_const<_Const, _Views>>...> __end) : __end_(__end) {}
  362. friend class zip_view<_Views...>;
  363. // hidden friend cannot access private member of iterator because they are friends of friends
  364. template <bool _OtherConst>
  365. _LIBCPP_HIDE_FROM_ABI static constexpr decltype(auto)
  366. __iter_current(zip_view<_Views...>::__iterator<_OtherConst> const& __it) {
  367. return (__it.__current_);
  368. }
  369. public:
  370. _LIBCPP_HIDE_FROM_ABI
  371. __sentinel() = default;
  372. _LIBCPP_HIDE_FROM_ABI
  373. constexpr __sentinel(__sentinel<!_Const> __i)
  374. requires _Const && (convertible_to<sentinel_t<_Views>, sentinel_t<__maybe_const<_Const, _Views>>> && ...)
  375. : __end_(std::move(__i.__end_)) {}
  376. template <bool _OtherConst>
  377. requires(sentinel_for<sentinel_t<__maybe_const<_Const, _Views>>, iterator_t<__maybe_const<_OtherConst, _Views>>> &&
  378. ...)
  379. _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator==(const __iterator<_OtherConst>& __x, const __sentinel& __y) {
  380. return ranges::__tuple_any_equals(__iter_current(__x), __y.__end_);
  381. }
  382. template <bool _OtherConst>
  383. requires(
  384. sized_sentinel_for<sentinel_t<__maybe_const<_Const, _Views>>, iterator_t<__maybe_const<_OtherConst, _Views>>> &&
  385. ...)
  386. _LIBCPP_HIDE_FROM_ABI friend constexpr common_type_t<range_difference_t<__maybe_const<_OtherConst, _Views>>...>
  387. operator-(const __iterator<_OtherConst>& __x, const __sentinel& __y) {
  388. const auto __diffs = ranges::__tuple_zip_transform(minus<>(), __iter_current(__x), __y.__end_);
  389. return std::apply(
  390. [](auto... __ds) {
  391. using _Diff = common_type_t<range_difference_t<__maybe_const<_OtherConst, _Views>>...>;
  392. return ranges::min({_Diff(__ds)...},
  393. [](auto __a, auto __b) { return ranges::__abs(__a) < ranges::__abs(__b); });
  394. },
  395. __diffs);
  396. }
  397. template <bool _OtherConst>
  398. requires(
  399. sized_sentinel_for<sentinel_t<__maybe_const<_Const, _Views>>, iterator_t<__maybe_const<_OtherConst, _Views>>> &&
  400. ...)
  401. _LIBCPP_HIDE_FROM_ABI friend constexpr common_type_t<range_difference_t<__maybe_const<_OtherConst, _Views>>...>
  402. operator-(const __sentinel& __y, const __iterator<_OtherConst>& __x) {
  403. return -(__x - __y);
  404. }
  405. };
  406. template <class... _Views>
  407. inline constexpr bool enable_borrowed_range<zip_view<_Views...>> = (enable_borrowed_range<_Views> && ...);
  408. namespace views {
  409. namespace __zip {
  410. struct __fn {
  411. _LIBCPP_HIDE_FROM_ABI constexpr auto operator()() const noexcept { return empty_view<tuple<>>{}; }
  412. template <class... _Ranges>
  413. _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Ranges&&... __rs) const
  414. noexcept(noexcept(zip_view<all_t<_Ranges&&>...>(std::forward<_Ranges>(__rs)...)))
  415. -> decltype(zip_view<all_t<_Ranges&&>...>(std::forward<_Ranges>(__rs)...)) {
  416. return zip_view<all_t<_Ranges>...>(std::forward<_Ranges>(__rs)...);
  417. }
  418. };
  419. } // namespace __zip
  420. inline namespace __cpo {
  421. inline constexpr auto zip = __zip::__fn{};
  422. } // namespace __cpo
  423. } // namespace views
  424. } // namespace ranges
  425. #endif // _LIBCPP_STD_VER >= 23
  426. _LIBCPP_END_NAMESPACE_STD
  427. _LIBCPP_POP_MACROS
  428. #endif // _LIBCPP___RANGES_ZIP_VIEW_H