//===----------------------------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // UNSUPPORTED: c++03, c++11, c++14, c++17, c++20 // UNSUPPORTED: libcpp-has-no-incomplete-ranges // std::views::zip #include #include #include #include #include #include #include "types.h" static_assert(std::is_invocable_v); static_assert(!std::is_invocable_v); static_assert(std::is_invocable_v); static_assert( std::is_invocable_v>); static_assert(!std::is_invocable_v); constexpr bool test() { { // zip zero arguments auto v = std::views::zip(); assert(std::ranges::empty(v)); static_assert(std::is_same_v>>); } { // zip a view int buffer[8] = {1, 2, 3, 4, 5, 6, 7, 8}; std::same_as> decltype(auto) v = std::views::zip(SizedRandomAccessView{buffer}); assert(std::ranges::size(v) == 8); static_assert(std::is_same_v, std::tuple>); } { // zip a viewable range std::array a{1, 2, 3}; std::same_as>>> decltype(auto) v = std::views::zip(a); assert(&(std::get<0>(*v.begin())) == &(a[0])); static_assert(std::is_same_v, std::tuple>); } { // zip the zip_view int buffer[8] = {1, 2, 3, 4, 5, 6, 7, 8}; std::same_as> decltype(auto) v = std::views::zip(SizedRandomAccessView{buffer}, SizedRandomAccessView{buffer}); std::same_as< std::ranges::zip_view>> decltype(auto) v2 = std::views::zip(v); static_assert(std::is_same_v, std::tuple>>); } return true; } int main(int, char**) { test(); static_assert(test()); return 0; }