libstdc++: Allow adjacent __maybe_present_t<false, ...> fields to overlap
[official-gcc.git] / libstdc++-v3 / testsuite / std / ranges / adaptors / sizeof.cc
blob08c01704d10bd477c94ec83de8ceba632dd14d5e
1 // Copyright (C) 2020-2024 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.
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-do compile { target c++20 } }
20 #include <ranges>
21 #include <string_view>
23 namespace ranges = std::ranges;
25 auto pred_f(int x) { return x%2 == 0; };
26 auto pred_l = [] (int x) { return x%2 == 0; };
28 auto func_f(int x) { return x*x; }
29 auto func_l = [] (int x) { return x*x; };
31 using V = ranges::subrange<int*, int*>;
32 constexpr auto ptr = sizeof(int*);
33 static_assert(sizeof(V) == 2*ptr);
35 static_assert(sizeof(ranges::take_view<V>) == 3*ptr);
36 static_assert(sizeof(ranges::drop_view<V>) == 3*ptr);
38 static_assert(sizeof(ranges::filter_view<V, decltype(&pred_f)>) == 4*ptr);
39 static_assert(sizeof(ranges::take_while_view<V, decltype(&pred_f)>) == 3*ptr);
40 static_assert(sizeof(ranges::drop_while_view<V, decltype(&pred_f)>) == 4*ptr);
41 static_assert(sizeof(ranges::transform_view<V, decltype(&func_f)>) == 3*ptr);
43 static_assert(sizeof(ranges::filter_view<V, decltype(pred_l)>) == 3*ptr);
44 static_assert(sizeof(ranges::take_while_view<V, decltype(pred_l)>) == 2*ptr);
45 static_assert(sizeof(ranges::drop_while_view<V, decltype(pred_l)>) == 3*ptr);
46 static_assert(sizeof(ranges::transform_view<V, decltype(func_l)>) == 2*ptr);
48 static_assert(sizeof(ranges::lazy_split_view<V, std::string_view>) == 4*ptr);
50 static_assert
51 (sizeof(ranges::reverse_view<ranges::filter_view<V, decltype(pred_l)>>) == 3*ptr);
53 #if __cpp_lib_ranges_slide
54 static_assert(sizeof(ranges::slide_view<V>) == 3*ptr);
55 #endif