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 | #include <iterator> |
12 | |
13 | #include "test_iterators.h" |
14 | |
15 | using sized_it = random_access_iterator<int*>; |
16 | static_assert(std::sized_sentinel_for<sized_it, sized_it>); |
17 | static_assert(std::sized_sentinel_for<std::move_iterator<sized_it>, std::move_iterator<sized_it>>); |
18 | |
19 | struct unsized_it { |
20 | using value_type = int; |
21 | using difference_type = std::ptrdiff_t; |
22 | |
23 | value_type& operator*() const; |
24 | bool operator==(const unsized_it&) const; |
25 | difference_type operator-(const unsized_it&) const { return 0; } |
26 | }; |
27 | |
28 | template <> |
29 | inline constexpr bool std::disable_sized_sentinel_for<unsized_it, unsized_it> = true; |
30 | |
31 | static_assert(!std::sized_sentinel_for<unsized_it, unsized_it>); |
32 | static_assert(!std::sized_sentinel_for<std::move_iterator<unsized_it>, std::move_iterator<unsized_it>>); |
33 | |