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
10 // UNSUPPORTED: libcpp-no-concepts
11 // UNSUPPORTED: libcpp-has-no-incomplete-ranges
12
13 // constexpr iterator(iterator<!Const> i);
14
15 #include <cassert>
16 #include <ranges>
17
18 #include "test_macros.h"
19 #include "../types.h"
20
test()21 constexpr bool test() {
22 int buffer[4][4] = {{1, 2, 3, 4}, {5, 6, 7, 8}, {9, 10, 11, 12}, {13, 14, 15, 16}};
23
24 CopyableChild children[4] = {CopyableChild(buffer[0]), CopyableChild(buffer[1]), CopyableChild(buffer[2]), CopyableChild(buffer[3])};
25 std::ranges::join_view jv(CopyableParent{children});
26 auto iter1 = jv.begin();
27 std::ranges::iterator_t<const decltype(jv)> iter2 = iter1;
28 assert(iter1 == iter2);
29
30 // We cannot create a non-const iterator from a const iterator.
31 static_assert(!std::constructible_from<decltype(iter1), decltype(iter2)>);
32
33 return true;
34 }
35
main(int,char **)36 int main(int, char**) {
37 test();
38 static_assert(test());
39
40 return 0;
41 }
42