1 // { dg-do run { target c++23 } }
5 #include <testsuite_hooks.h>
6 #include <testsuite_iterators.h>
7 #include <testsuite_allocator.h>
9 template<typename Range
, typename Alloc
>
13 // The vector's value_type.
14 using V
= typename
std::allocator_traits
<Alloc
>::value_type
;
16 // The range's value_type.
17 using T
= std::ranges::range_value_t
<Range
>;
18 T a
[]{1,2,3,4,5,6,7,8,9};
20 auto eq
= [](const std::vector
<V
, Alloc
>& l
, std::span
<T
> r
) {
21 if (l
.size() != r
.size())
23 for (auto i
= 0u; i
< l
.size(); ++i
)
32 std::vector
<V
, Alloc
> v
;
34 VERIFY( eq(v
, {a
, 4}) );
35 v
.append_range(r5
); // larger than v.capacity()
37 v
.append_range(Range(a
, a
));
40 v
.append_range(Range(a
, a
));
44 template<typename Range
>
48 do_test
<Range
, std::allocator
<int>>();
49 do_test
<Range
, __gnu_test::SimpleAllocator
<int>>();
55 using namespace __gnu_test
;
57 do_test_a
<test_forward_range
<int>>();
58 do_test_a
<test_forward_sized_range
<int>>();
59 do_test_a
<test_sized_range_sized_sent
<int, forward_iterator_wrapper
>>();
61 do_test_a
<test_input_range
<int>>();
62 do_test_a
<test_input_sized_range
<int>>();
63 do_test_a
<test_sized_range_sized_sent
<int, input_iterator_wrapper
>>();
65 do_test_a
<test_range
<int, input_iterator_wrapper_nocopy
>>();
66 do_test_a
<test_sized_range
<int, input_iterator_wrapper_nocopy
>>();
67 do_test_a
<test_sized_range_sized_sent
<int, input_iterator_wrapper_nocopy
>>();
69 do_test_a
<test_forward_range
<short>>();
70 do_test_a
<test_input_range
<short>>();
72 // Not lvalue-convertible to int
75 operator int() && { return val
; }
76 bool operator==(int b
) const { return b
== val
; }
79 using rvalue_input_range
= test_range
<C
, input_iterator_wrapper_rval
>;
80 do_test
<rvalue_input_range
, std::allocator
<int>>();
88 // XXX: this doesn't test the non-forward_range code paths are constexpr.
89 do_test
<std::span
<short>, std::allocator
<int>>();
96 static_assert( test_constexpr() );