comparison libstdc++-v3/testsuite/std/ranges/subrange/lwg3286.cc @ 152:2b5abeee2509

update gcc11
author anatofuz
date Mon, 25 May 2020 07:50:57 +0900
parents
children
comparison
equal deleted inserted replaced
145:1830386684a0 152:2b5abeee2509
1 // Copyright (C) 2020 Free Software Foundation, Inc.
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>
22 #include <testsuite_iterators.h>
23 #include <testsuite_hooks.h>
24
25 using __gnu_test::test_input_range;
26
27 namespace ranges = std::ranges;
28
29 struct my_range
30 {
31 static inline int x[] = {1,2,3};
32 static inline test_input_range<int> r{x};
33
34 bool called_begin = false;
35
36 auto
37 begin()
38 {
39 called_begin = true;
40 return r.begin();
41 }
42
43 auto
44 end()
45 {
46 return r.end();
47 }
48
49 ranges::range_difference_t<decltype(r)>
50 size()
51 {
52 VERIFY( !called_begin );
53 return 3;
54 }
55 };
56
57 void
58 test01()
59 {
60 my_range r;
61 static_assert(!ranges::forward_range<my_range>);
62 static_assert(ranges::sized_range<my_range>);
63 ranges::subrange sr = r;
64 VERIFY( ranges::size(sr) == 3 );
65 }
66
67 int
68 main()
69 {
70 test01();
71 }