File tree Expand file tree Collapse file tree 10 files changed +55
-61
lines changed
test/std/ranges/range.adaptors/range.concat Expand file tree Collapse file tree 10 files changed +55
-61
lines changed Original file line number Diff line number Diff line change @@ -578,14 +578,15 @@ class concat_view<_Views...>::__iterator : public __concat_view_iterator_categor
578
578
!__x.__it_ .valueless_by_exception (),
579
579
" Trying to subtract a valuess iterators of concat_view from the default sentinel." );
580
580
return __x.__invoke_at_index ([&]<std::size_t __index_x>() -> difference_type {
581
- auto __dx = ranges::distance (ranges::begin (std::get<__index_x>(__x.__parent_ ->__views_ )), __x.__it_ );
581
+ auto __dx =
582
+ ranges::distance (std::get<__index_x>(__x.__it_ ), ranges::end (std::get<__index_x>(__x.__parent_ ->__views_ )));
582
583
difference_type __s = [&]<std::size_t __start, std::size_t __end>(this auto && self) -> difference_type {
583
584
if constexpr (__start < __end) {
584
585
return ranges::size (std::get<__start>(__x.__parent_ ->__views_ )) +
585
586
self.template operator ()<__start + 1 , __end>();
586
587
}
587
588
return 0 ;
588
- }.template operator ()<0 , __index_x >();
589
+ }.template operator ()<__index_x + 1 , sizeof ...(_Views) >();
589
590
return -(__dx + __s);
590
591
});
591
592
}
@@ -595,7 +596,7 @@ class concat_view<_Views...>::__iterator : public __concat_view_iterator_categor
595
596
...) &&
596
597
(__apply_drop_first<_Const, _Views...>::value)
597
598
{
598
- -(__x - default_sentinel);
599
+ return -(__x - default_sentinel);
599
600
}
600
601
};
601
602
Original file line number Diff line number Diff line change 9
9
// REQUIRES: std-at-least-c++26
10
10
11
11
#include < ranges>
12
-
13
12
#include < cassert>
14
- #include < concepts>
15
13
#include < initializer_list>
16
- #include < type_traits>
17
- #include < utility>
18
- #include < vector>
19
14
20
15
#include " test_iterators.h"
21
16
#include " test_range.h"
Original file line number Diff line number Diff line change @@ -20,8 +20,8 @@ constexpr void general_tests() {
20
20
// Check the return type of `.begin()`
21
21
{
22
22
std::ranges::concat_view view (v1, v2);
23
- using FilterIterator = std::ranges::iterator_t <decltype (view)>;
24
- ASSERT_SAME_TYPE (FilterIterator , decltype (view.begin ()));
23
+ using ConcatIterator = std::ranges::iterator_t <decltype (view)>;
24
+ ASSERT_SAME_TYPE (ConcatIterator , decltype (view.begin ()));
25
25
}
26
26
}
27
27
Original file line number Diff line number Diff line change 10
10
11
11
#include < cassert>
12
12
#include < ranges>
13
- #include < utility>
14
13
15
- #include " test_convertible.h"
16
14
#include " test_macros.h"
17
15
#include " types.h"
18
16
Original file line number Diff line number Diff line change 11
11
#include < ranges>
12
12
13
13
#include < cassert>
14
- #include < concepts>
15
- #include < type_traits>
16
- #include < iterator>
17
14
#include " test_iterators.h"
18
15
19
16
struct Range : std::ranges::view_base {
Original file line number Diff line number Diff line change 12
12
13
13
#include < array>
14
14
#include < cassert>
15
- #include < concepts>
16
- #include < utility>
17
- #include < __type_traits/maybe_const.h>
18
15
#include " test_iterators.h"
19
- #include " test_macros.h"
20
16
#include " test_range.h"
21
17
22
18
#include " ../types.h"
Original file line number Diff line number Diff line change 12
12
13
13
#include < array>
14
14
#include < cassert>
15
- #include < concepts>
16
- #include < iterator>
17
- #include < utility>
18
- #include < vector>
19
- #include " test_iterators.h"
20
15
#include " test_macros.h"
21
16
#include " ../types.h"
22
- #include < iostream>
23
17
24
18
constexpr void test () {
25
19
// Test with a single satisfied value
@@ -82,36 +76,6 @@ constexpr void test() {
82
76
assert (result == view.end ());
83
77
assert (it == (result - 1 ));
84
78
}
85
-
86
- // Test two iterators
87
- {
88
- std::array<int , 5 > array1{0 , 1 };
89
- std::array<int , 5 > array2{2 , 3 };
90
- std::ranges::concat_view view (std::views::all (array1), std::views::all (array2));
91
- auto it1 = view.begin ();
92
- it1++;
93
- it1++;
94
- auto it2 = view.begin ();
95
- auto res = it1 - it2;
96
- std::cout << res << std::endl;
97
- assert (res == 2 );
98
- }
99
-
100
- // Test one iterator and one sentinel
101
- {
102
- std::array<int , 5 > array1{0 , 1 };
103
- std::array<int , 5 > array2{2 , 3 };
104
- std::ranges::concat_view view (std::views::all (array1), std::views::all (array2));
105
- auto it1 = view.begin ();
106
- it1++;
107
- it1++;
108
- it1++;
109
- it1++;
110
- auto it2 = view.begin ();
111
- auto res = it1 - it2;
112
- std::cout << res << std::endl;
113
- assert (res == 4 );
114
- }
115
79
}
116
80
117
81
int main (int , char **) {
Original file line number Diff line number Diff line change 12
12
13
13
#include < array>
14
14
#include < cassert>
15
- #include < concepts>
16
- #include < cstddef>
17
- #include < utility>
18
15
#include " test_iterators.h"
19
- #include " test_macros.h"
20
16
#include " ../types.h"
21
17
22
18
template <class Iter , class ValueType = int , class Sent = sentinel_wrapper<Iter>>
Original file line number Diff line number Diff line change 10
10
11
11
#include < ranges>
12
12
13
- #include < iostream>
14
13
#include < array>
15
14
#include < cassert>
16
15
#include < concepts>
17
16
#include < type_traits>
18
17
#include < utility>
19
18
#include " test_iterators.h"
20
- #include " test_macros.h"
21
19
#include " ../types.h"
22
20
23
21
template <class Iterator >
Original file line number Diff line number Diff line change
1
+ // ===----------------------------------------------------------------------===//
2
+ //
3
+ // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4
+ // See https://llvm.org/LICENSE.txt for license information.
5
+ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6
+ //
7
+ // ===----------------------------------------------------------------------===//
8
+
9
+ // REQUIRES: std-at-least-c++26
10
+
11
+ #include < ranges>
12
+
13
+ #include < array>
14
+ #include < cassert>
15
+ #include < iterator>
16
+ #include " test_iterators.h"
17
+ #include " test_macros.h"
18
+ #include " ../types.h"
19
+
20
+ constexpr void test () {
21
+
22
+ // Test two iterators
23
+ {
24
+ std::array<int , 2 > array1{0 , 1 };
25
+ std::array<int , 2 > array2{2 , 3 };
26
+ std::ranges::concat_view view (std::views::all (array1), std::views::all (array2));
27
+ auto it1 = view.begin ();
28
+ it1++;
29
+ it1++;
30
+ auto it2 = view.begin ();
31
+ auto res = it1 - it2;
32
+ assert (res == 2 );
33
+ }
34
+
35
+ // Test one iterator and one sentinel
36
+ {
37
+ std::array<int , 2 > array1{0 , 1 };
38
+ std::array<int , 2 > array2{2 , 3 };
39
+ std::ranges::concat_view view (std::views::all (array1), std::views::all (array2));
40
+ auto it1 = view.begin ();
41
+ auto res = std::default_sentinel_t {} - it1;
42
+ assert (res == 4 );
43
+ }
44
+ }
45
+
46
+ int main (int , char **) {
47
+ test ();
48
+ return 0 ;
49
+ }
You can’t perform that action at this time.
0 commit comments