zip_view.h 18 KB

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