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

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