|
10 | 10 | // <iterator> |
11 | 11 |
|
12 | 12 | // __bounded_iter<_Iter> |
| 13 | +// __static_bounded_iter<_Iter> |
13 | 14 | // __wrap_iter<_Iter> |
14 | 15 |
|
15 | 16 | // Verify that libc++-wrapped iterators do not permit slicing conversion or construction. |
16 | 17 |
|
17 | 18 | #include <array> |
18 | | -#include <vector> |
19 | 19 | #include <span> |
20 | 20 | #include <type_traits> |
| 21 | +#include <vector> |
21 | 22 |
|
22 | 23 | #include "test_macros.h" |
23 | 24 |
|
24 | 25 | struct Base {}; |
25 | 26 | struct Derived : Base {}; |
26 | 27 |
|
27 | | -#ifdef _LIBCPP_ABI_USE_WRAP_ITER_IN_STD_ARRAY |
28 | | -static_assert(!std::is_convertible<std::array<Derived, 1>::iterator, std::array<Base, 1>::iterator>::value, ""); |
29 | | -static_assert(!std::is_convertible<std::array<Derived, 1>::iterator, std::array<Base, 1>::const_iterator>::value, ""); |
30 | | -static_assert(!std::is_convertible<std::array<Derived, 1>::const_iterator, std::array<Base, 1>::const_iterator>::value, |
31 | | - ""); |
32 | | -static_assert(!std::is_constructible<std::array<Base, 1>::iterator, std::array<Derived, 1>::iterator>::value, ""); |
33 | | -static_assert(!std::is_constructible<std::array<Base, 1>::const_iterator, std::array<Derived, 1>::iterator>::value, ""); |
34 | | -static_assert( |
35 | | - !std::is_constructible<std::array<Base, 1>::const_iterator, std::array<Derived, 1>::const_iterator>::value, ""); |
36 | | -#endif |
| 28 | +template <class B, class D, bool = std::is_pointer<typename std::array<B, 1>::iterator>::value> |
| 29 | +struct test_array_helper : std::true_type { |
| 30 | + typedef typename std::array<B, 1>::iterator BaseIter; |
| 31 | + typedef typename std::array<D, 1>::iterator DerivedIter; |
| 32 | + typedef typename std::array<B, 1>::const_iterator BaseConstIter; |
| 33 | + typedef typename std::array<D, 1>::const_iterator DerivedConstIter; |
| 34 | + |
| 35 | + static_assert(!std::is_convertible<DerivedIter, BaseIter>::value, ""); |
| 36 | + static_assert(!std::is_convertible<DerivedIter, BaseConstIter>::value, ""); |
| 37 | + static_assert(!std::is_convertible<DerivedConstIter, BaseConstIter>::value, ""); |
| 38 | + static_assert(!std::is_constructible<BaseIter, DerivedIter>::value, ""); |
| 39 | + static_assert(!std::is_constructible<BaseConstIter, DerivedIter>::value, ""); |
| 40 | + static_assert(!std::is_constructible<BaseConstIter, DerivedConstIter>::value, ""); |
| 41 | +}; |
| 42 | + |
| 43 | +template <class B, class D> |
| 44 | +struct test_array_helper<B, D, true> : std::true_type {}; |
| 45 | + |
| 46 | +static_assert(test_array_helper<Base, Derived>::value, ""); |
37 | 47 |
|
38 | 48 | static_assert(!std::is_convertible<std::vector<Derived>::iterator, std::vector<Base>::iterator>::value, ""); |
39 | 49 | static_assert(!std::is_convertible<std::vector<Derived>::iterator, std::vector<Base>::const_iterator>::value, ""); |
|
0 commit comments