Skip to content

Commit 150eed3

Browse files
committed
test: view CTAD
1 parent 62c2d22 commit 150eed3

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
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+
9+
// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
10+
11+
// template <class... Vs>
12+
// cartesian_product_view(Vs&&...) -> cartesian_product_view<views::all_t<Vs>...>;
13+
14+
#include <cassert>
15+
#include <ranges>
16+
#include <utility>
17+
18+
struct Container {
19+
int* begin() const;
20+
int* end() const;
21+
};
22+
23+
struct View : std::ranges::view_base {
24+
int* begin() const;
25+
int* end() const;
26+
};
27+
28+
void testCTAD() {
29+
static_assert(std::is_same_v<decltype(std::ranges::cartesian_product_view(Container{})),
30+
std::ranges::cartesian_product_view<std::ranges::owning_view<Container>>>);
31+
32+
static_assert(std::is_same_v<decltype(std::ranges::cartesian_product_view(Container{}, View{})),
33+
std::ranges::cartesian_product_view<std::ranges::owning_view<Container>, View>>);
34+
35+
Container c{};
36+
static_assert(
37+
std::is_same_v<
38+
decltype(std::ranges::cartesian_product_view(Container{}, View{}, c)),
39+
std::ranges::
40+
cartesian_product_view<std::ranges::owning_view<Container>, View, std::ranges::ref_view<Container>>>);
41+
}

0 commit comments

Comments
 (0)