]>
Commit | Line | Data |
---|---|---|
8d9254fc | 1 | // Copyright (C) 2019-2020 Free Software Foundation, Inc. |
37f33df7 JW |
2 | // |
3 | // This file is part of the GNU ISO C++ Library. This library is free | |
4 | // software; you can redistribute it and/or modify it under the | |
5 | // terms of the GNU General Public License as published by the | |
6 | // Free Software Foundation; either version 3, or (at your option) | |
7 | // any later version. | |
8 | ||
9 | // This library is distributed in the hope that it will be useful, | |
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | // GNU General Public License for more details. | |
13 | ||
14 | // You should have received a copy of the GNU General Public License along | |
15 | // with this library; see the file COPYING3. If not see | |
16 | // <http://www.gnu.org/licenses/>. | |
17 | ||
18 | // { dg-options "-std=gnu++2a" } | |
19 | // { dg-do compile { target c++2a } } | |
20 | ||
21 | #include <ranges> | |
22 | #include <vector> | |
23 | #include <set> | |
24 | #include <unordered_set> | |
25 | #include <regex> | |
26 | #include <testsuite_iterators.h> | |
27 | ||
28 | static_assert(std::ranges::view<std::vector<int>>); | |
29 | static_assert(!std::ranges::view<const std::vector<int>>); | |
30 | static_assert(!std::ranges::view<std::initializer_list<int>>); | |
31 | static_assert(!std::ranges::view<const std::initializer_list<int>>); | |
32 | static_assert(!std::ranges::view<std::set<int>>); | |
33 | static_assert(!std::ranges::view<const std::set<int>>); | |
34 | static_assert(!std::ranges::view<std::multiset<int>>); | |
35 | static_assert(!std::ranges::view<std::unordered_set<int>>); | |
36 | static_assert(!std::ranges::view<std::unordered_multiset<int>>); | |
37 | static_assert(!std::ranges::view<std::cmatch>); | |
38 | ||
39 | // const test_random_access_range<T> is not a range: | |
40 | static_assert(!std::ranges::view<__gnu_test::test_random_access_range<int>>); | |
41 | ||
42 | template<typename T> | |
43 | struct test_view | |
44 | : __gnu_test::test_random_access_range<T>, std::ranges::view_base | |
45 | { | |
46 | // views must be default-initializable: | |
47 | test_view() : __gnu_test::test_random_access_range<T>(nullptr, nullptr) { } | |
48 | }; | |
49 | ||
50 | static_assert(std::ranges::view<test_view<int>>); | |
51 | ||
52 | template<> | |
53 | constexpr bool std::ranges::enable_view<test_view<long>> = false; | |
54 | ||
55 | static_assert(!std::ranges::view<test_view<long>>); |