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-has-no-incomplete-ranges
11 
12 // constexpr explicit inner-iterator::inner-iterator(outer-iterator<Const> i);
13 
14 #include <ranges>
15 
16 #include "../types.h"
17 
18 static_assert(!std::is_constructible_v<InnerIterNonConst, OuterIterConst>);
19 
20 template <class Inner, class Outer>
test_impl()21 constexpr void test_impl() {
22   [[maybe_unused]] Inner i(Outer{});
23   // Verify that the constructor is `explicit`.
24   static_assert(!std::is_convertible_v<Outer, Inner>);
25 }
26 
test()27 constexpr bool test() {
28   test_impl<InnerIterForward, OuterIterForward>();
29   test_impl<InnerIterInput, OuterIterInput>();
30 // Is only constructible if both the outer and the inner iterators have the same constness.
31   test_impl<InnerIterConst, OuterIterConst>();
32 // Note: this works because of an implicit conversion (`OuterIterNonConst` is converted to `OuterIterConst`).
33   test_impl<InnerIterConst, OuterIterNonConst>();
34   test_impl<InnerIterNonConst, OuterIterNonConst>();
35 
36   return true;
37 }
38 
main(int,char **)39 int main(int, char**) {
40   test();
41   static_assert(test());
42 
43   return 0;
44 }
45