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
17template<class T> concept HasMinus = requires (T t) { t - t; };
18
19using sized_it = random_access_iterator<int*>;
20static_assert( std::sized_sentinel_for<sized_it, sized_it>);
21static_assert( std::sized_sentinel_for<std::reverse_iterator<sized_it>, std::reverse_iterator<sized_it>>);
22static_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.
25using unsized_it = bidirectional_iterator<int*>;
26static_assert(!std::sized_sentinel_for<unsized_it, unsized_it>);
27static_assert(!std::sized_sentinel_for<std::reverse_iterator<unsized_it>, std::reverse_iterator<unsized_it>>);
28static_assert(!HasMinus<std::reverse_iterator<unsized_it>>);
29

source code of libcxx/test/std/iterators/predef.iterators/reverse.iterators/sized_sentinel.compile.pass.cpp