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 | // std::views::istream<T> |
13 | |
14 | #include <cassert> |
15 | #include <ranges> |
16 | #include <sstream> |
17 | #include <type_traits> |
18 | |
19 | #include "test_macros.h" |
20 | #include "utils.h" |
21 | |
22 | static_assert(!std::is_invocable_v<decltype((std::views::istream<int>))>); |
23 | static_assert(std::is_invocable_v<decltype((std::views::istream<int>)), std::istream&>); |
24 | static_assert(!std::is_invocable_v<decltype((std::views::istream<int>)), const std::istream&>); |
25 | static_assert(!std::is_invocable_v<decltype((std::views::istream<int>)), int>); |
26 | |
27 | #ifndef TEST_HAS_NO_WIDE_CHARACTERS |
28 | static_assert(std::is_invocable_v<decltype((std::views::istream<int>)), std::wistream&>); |
29 | static_assert(!std::is_invocable_v<decltype((std::views::istream<int>)), const std::wistream&>); |
30 | #endif |
31 | |
32 | template <class CharT> |
33 | void test() { |
34 | auto iss = make_string_stream<CharT>("12 3" ); |
35 | auto isv = std::views::istream<int>(iss); |
36 | auto it = isv.begin(); |
37 | assert(*it == 12); |
38 | } |
39 | |
40 | int main(int, char**) { |
41 | test<char>(); |
42 | #ifndef TEST_HAS_NO_WIDE_CHARACTERS |
43 | test<wchar_t>(); |
44 | #endif |
45 | |
46 | return 0; |
47 | } |
48 | |