|
| 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 | + |
| 10 | +// <iterator> |
| 11 | + |
| 12 | +// __segmented_iterator_traits<_Iter> |
| 13 | + |
| 14 | +// verifies that __segmented_iterator_traits<_Iter> does not result in implicit |
| 15 | +// template instantaition, which may cause hard errors in SFINAE. |
| 16 | + |
| 17 | +// XFAIL: FROZEN-CXX03-HEADERS-FIXME |
| 18 | + |
| 19 | +#include <array> |
| 20 | +#include <deque> |
| 21 | +#include <list> |
| 22 | +#include <ranges> |
| 23 | +#include <vector> |
| 24 | +#include <__iterator/segmented_iterator.h> |
| 25 | + |
| 26 | +#include "test_iterators.h" |
| 27 | +#include "test_macros.h" |
| 28 | + |
| 29 | +template <class Iter> |
| 30 | +struct is_segmented_random_access_iterator |
| 31 | + : std::bool_constant<std::__is_segmented_iterator<Iter>::value && |
| 32 | + std::__has_random_access_iterator_category< |
| 33 | + typename std::__segmented_iterator_traits<Iter>::__local_iterator>::value> {}; |
| 34 | + |
| 35 | +int main(int, char**) { |
| 36 | + static_assert(is_segmented_random_access_iterator<std::deque<int>::iterator>::value, ""); |
| 37 | + static_assert(!is_segmented_random_access_iterator<std::vector<int>::iterator>::value, ""); |
| 38 | + static_assert(!is_segmented_random_access_iterator<std::list<int>::iterator>::value, ""); |
| 39 | + static_assert(!is_segmented_random_access_iterator<std::array<int, 0>::iterator>::value, ""); |
| 40 | + static_assert(!is_segmented_random_access_iterator<cpp17_input_iterator<int*>>::value, ""); |
| 41 | + static_assert(!is_segmented_random_access_iterator<forward_iterator<int*>>::value, ""); |
| 42 | + static_assert(!is_segmented_random_access_iterator<random_access_iterator<int*>>::value, ""); |
| 43 | + static_assert(!is_segmented_random_access_iterator<int*>::value, ""); |
| 44 | + |
| 45 | +#if TEST_STD_VER >= 20 |
| 46 | + using join_view_iterator = decltype((std::declval<std::vector<std::vector<int > >&>() | std::views::join).begin()); |
| 47 | + static_assert(is_segmented_random_access_iterator<join_view_iterator>::value, ""); |
| 48 | +#endif |
| 49 | + |
| 50 | + return 0; |
| 51 | +} |
0 commit comments