[OpenACC] Create AST nodes for 'data' constructs
[llvm-project.git] / libcxx / test / std / ranges / range.factories / range.istream.view / range.concept.compile.pass.cpp
blob9141632bab744e6bfb919d9cd860b2aac08216ba
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 //===----------------------------------------------------------------------===//
9 // UNSUPPORTED: no-localization
10 // UNSUPPORTED: c++03, c++11, c++14, c++17
12 // concept checking istream_view
14 #include <istream>
15 #include <ranges>
17 #include "test_macros.h"
19 template <class Val, class CharT, class Traits = std::char_traits<CharT>>
20 concept HasIstreamView = requires { typename std::ranges::basic_istream_view<Val, CharT, Traits>; };
22 static_assert(HasIstreamView<int, char>);
24 #ifndef TEST_HAS_NO_WIDE_CHARACTERS
25 static_assert(HasIstreamView<int, wchar_t>);
26 #endif
28 // Unmovable Val
29 struct Unmovable {
30 Unmovable() = default;
31 Unmovable(Unmovable&&) = delete;
32 template <class CharT>
33 friend std::basic_istream<CharT>& operator>>(std::basic_istream<CharT>& x, const Unmovable&) {
34 return x;
37 static_assert(!HasIstreamView<Unmovable, char>);
39 #ifndef TEST_HAS_NO_WIDE_CHARACTERS
40 static_assert(!HasIstreamView<Unmovable, wchar_t>);
41 #endif
43 // !default_initializable<Val>
44 struct NoDefaultCtor {
45 NoDefaultCtor(int) {}
46 friend std::istream& operator>>(std::istream& x, const NoDefaultCtor&) { return x; }
48 static_assert(!HasIstreamView<NoDefaultCtor, char>);
49 #ifndef TEST_HAS_NO_WIDE_CHARACTERS
50 static_assert(!HasIstreamView<NoDefaultCtor, wchar_t>);
51 #endif
53 // !stream-extractable<Val, CharT, Traits>
54 struct Foo {};
55 static_assert(!HasIstreamView<Foo, char>);
56 #ifndef TEST_HAS_NO_WIDE_CHARACTERS
57 static_assert(!HasIstreamView<Foo, wchar_t>);
58 #endif
60 template <class T>
61 concept OnlyInputRange = std::ranges::input_range<T> && !std::ranges::forward_range<T>;
63 static_assert(OnlyInputRange<std::ranges::istream_view<int>>);
64 static_assert(OnlyInputRange<std::ranges::istream_view<long>>);
65 static_assert(OnlyInputRange<std::ranges::istream_view<double>>);
66 static_assert(OnlyInputRange<std::ranges::istream_view<char>>);
68 #ifndef TEST_HAS_NO_WIDE_CHARACTERS
69 static_assert(OnlyInputRange<std::ranges::wistream_view<int>>);
70 static_assert(OnlyInputRange<std::ranges::wistream_view<long>>);
71 static_assert(OnlyInputRange<std::ranges::wistream_view<double>>);
72 static_assert(OnlyInputRange<std::ranges::wistream_view<wchar_t>>);
73 #endif