| 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 | // reverse_iterator |
| 12 | |
| 13 | #include <iterator> |
| 14 | |
| 15 | #include "test_iterators.h" |
| 16 | |
| 17 | template<class T> concept HasMinus = requires (T t) { t - t; }; |
| 18 | |
| 19 | using sized_it = random_access_iterator<int*>; |
| 20 | static_assert( std::sized_sentinel_for<sized_it, sized_it>); |
| 21 | static_assert( std::sized_sentinel_for<std::reverse_iterator<sized_it>, std::reverse_iterator<sized_it>>); |
| 22 | static_assert( HasMinus<std::reverse_iterator<sized_it>>); |
| 23 | |
| 24 | // Check that `sized_sentinel_for` is false for `reverse_iterator`s if it is false for the underlying iterators. |
| 25 | using unsized_it = bidirectional_iterator<int*>; |
| 26 | static_assert(!std::sized_sentinel_for<unsized_it, unsized_it>); |
| 27 | static_assert(!std::sized_sentinel_for<std::reverse_iterator<unsized_it>, std::reverse_iterator<unsized_it>>); |
| 28 | static_assert(!HasMinus<std::reverse_iterator<unsized_it>>); |
| 29 | |