]>
gcc.gnu.org Git - gcc.git/blob - libstdc++-v3/testsuite/std/ranges/view.cc
1 // Copyright (C) 2019-2021 Free Software Foundation, Inc.
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)
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.
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/>.
18 // { dg-options "-std=gnu++2a" }
19 // { dg-do compile { target c++2a } }
23 #include <string_view>
24 #include <experimental/string_view>
28 #include <unordered_set>
30 #include <testsuite_iterators.h>
32 static_assert(std::ranges::view
<std::span
<int>>);
33 static_assert(std::ranges::view
<std::span
<int, 0>>);
34 static_assert(!std::ranges::view
<std::span
<int, 1>>);
35 static_assert(std::ranges::view
<std::string_view
>);
36 static_assert(std::ranges::view
<std::experimental::string_view
>);
38 static_assert(!std::ranges::view
<std::vector
<int>>);
39 static_assert(!std::ranges::view
<const std::vector
<int>>);
40 static_assert(!std::ranges::view
<std::initializer_list
<int>>);
41 static_assert(!std::ranges::view
<const std::initializer_list
<int>>);
42 static_assert(!std::ranges::view
<std::set
<int>>);
43 static_assert(!std::ranges::view
<const std::set
<int>>);
44 static_assert(!std::ranges::view
<std::multiset
<int>>);
45 static_assert(!std::ranges::view
<std::unordered_set
<int>>);
46 static_assert(!std::ranges::view
<std::unordered_multiset
<int>>);
47 static_assert(!std::ranges::view
<std::cmatch
>);
49 // const test_random_access_range<T> is not a range:
50 static_assert(!std::ranges::view
<__gnu_test::test_random_access_range
<int>>);
54 : __gnu_test::test_random_access_range
<T
>, std::ranges::view_base
56 // views must be default-initializable:
57 test_view() : __gnu_test::test_random_access_range
<T
>(nullptr, nullptr) { }
60 static_assert(std::ranges::view
<test_view
<int>>);
63 constexpr bool std::ranges::enable_view
<test_view
<long>> = false;
65 static_assert(!std::ranges::view
<test_view
<long>>);
This page took 0.036373 seconds and 5 git commands to generate.