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: no-localization
10// UNSUPPORTED: c++03, c++11, c++14, c++17
11
12// constexpr default_sentinel_t end() const noexcept;
13
14#include <cassert>
15#include <ranges>
16#include <sstream>
17
18#include "test_macros.h"
19#include "utils.h"
20
21template <class T>
22concept NoexceptEnd =
23 requires(T t) {
24 { t.end() } noexcept;
25 };
26
27static_assert(NoexceptEnd<std::ranges::istream_view<int>>);
28static_assert(NoexceptEnd<const std::ranges::istream_view<int>>);
29
30#ifndef TEST_HAS_NO_WIDE_CHARACTERS
31static_assert(NoexceptEnd<std::ranges::wistream_view<int>>);
32static_assert(NoexceptEnd<const std::ranges::wistream_view<int>>);
33#endif
34
35template <class CharT>
36void test() {
37 auto iss = make_string_stream<CharT>("12");
38 std::ranges::basic_istream_view<int, CharT> isv{iss};
39 [[maybe_unused]] std::same_as<std::default_sentinel_t> auto sent = isv.end();
40}
41
42int main(int, char**) {
43 test<char>();
44#ifndef TEST_HAS_NO_WIDE_CHARACTERS
45 test<wchar_t>();
46#endif
47
48 return 0;
49}
50

source code of libcxx/test/std/ranges/range.factories/range.istream.view/end.pass.cpp