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