]> git.ipfire.org Git - thirdparty/gcc.git/blame - libstdc++-v3/testsuite/std/ranges/iota/difference_type.cc
Update copyright years.
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / std / ranges / iota / difference_type.cc
CommitLineData
7adcbafe 1// Copyright (C) 2020-2022 Free Software Foundation, Inc.
e6c76f0d
PP
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 run { target c++2a } }
20
21#include <ranges>
9af65c2b 22#include <limits>
e6c76f0d
PP
23#include <testsuite_hooks.h>
24
25void
26test01()
27{
28 using I = unsigned long long;
29 auto imax = std::numeric_limits<I>::max();
30 std::ranges::iota_view<I, I> i(0, imax);
31 auto begin = i.begin();
32 static_assert( std::input_or_output_iterator<decltype(begin)> );
33 auto size = std::ranges::end(i) - std::ranges::begin(i);
34 VERIFY( size > 0 );
35 VERIFY( size == imax );
36}
37
38void
39test02()
40{
41#if !defined(__STRICT_ANSI__) && __SIZEOF_INT128__
42 using I = unsigned __int128;
43 auto imax = std::numeric_limits<I>::max();
44 std::ranges::iota_view<I, I> i(0, imax);
45 auto begin = i.begin();
46 static_assert( std::input_or_output_iterator<decltype(begin)> );
47 auto size = std::ranges::end(i) - std::ranges::begin(i);
48 VERIFY( size > 0 );
49 VERIFY( size == imax );
50#endif
51}
52
53int
54main()
55{
56 test01();
57 test02();
58}