]> git.ipfire.org Git - thirdparty/gcc.git/blame - libstdc++-v3/testsuite/std/ranges/view.cc
Update copyright years.
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / std / ranges / view.cc
CommitLineData
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
28static_assert(std::ranges::view<std::vector<int>>);
29static_assert(!std::ranges::view<const std::vector<int>>);
30static_assert(!std::ranges::view<std::initializer_list<int>>);
31static_assert(!std::ranges::view<const std::initializer_list<int>>);
32static_assert(!std::ranges::view<std::set<int>>);
33static_assert(!std::ranges::view<const std::set<int>>);
34static_assert(!std::ranges::view<std::multiset<int>>);
35static_assert(!std::ranges::view<std::unordered_set<int>>);
36static_assert(!std::ranges::view<std::unordered_multiset<int>>);
37static_assert(!std::ranges::view<std::cmatch>);
38
39// const test_random_access_range<T> is not a range:
40static_assert(!std::ranges::view<__gnu_test::test_random_access_range<int>>);
41
42template<typename T>
43struct 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
50static_assert(std::ranges::view<test_view<int>>);
51
52template<>
53constexpr bool std::ranges::enable_view<test_view<long>> = false;
54
55static_assert(!std::ranges::view<test_view<long>>);