File tree Expand file tree Collapse file tree 2 files changed +36
-6
lines changed
test/std/ranges/range.adaptors/range.concat Expand file tree Collapse file tree 2 files changed +36
-6
lines changed Original file line number Diff line number Diff line change @@ -111,7 +111,7 @@ concept __concat_is_bidirectional =
111111 (__all_bidirectional<_Const, _Rs...>) && (__all_common_ignore_last<_Const, _Rs...>::value);
112112
113113template <input_range... _Views>
114- requires (view<_Views> && ...) && (sizeof ...(_Views) > 0 ) && __concatable<_Views...>
114+ requires (( view<_Views> && ...) && (sizeof ...(_Views) > 0 ) && __concatable<_Views...>)
115115class concat_view : public view_interface <concat_view<_Views...>> {
116116 tuple<_Views...> __views_;
117117
@@ -210,7 +210,7 @@ struct __concat_view_iterator_category<_Const, _Views...> {
210210};
211211
212212template <input_range... _Views>
213- requires (view<_Views> && ...) && (sizeof ...(_Views) > 0 ) && __concatable<_Views...>
213+ requires (( view<_Views> && ...) && (sizeof ...(_Views) > 0 ) && __concatable<_Views...>)
214214template <bool _Const>
215215class concat_view <_Views...>::__iterator : public __concat_view_iterator_category<_Const, _Views...> {
216216public:
Original file line number Diff line number Diff line change 1010
1111#include < cassert>
1212#include < ranges>
13+ #include < string>
1314#include < vector>
1415#include " test_macros.h"
1516
17+ struct NoSizeRange : std::ranges::view_base {
18+ constexpr auto size () { return 0 ; }
19+ };
20+
1621int main (int , char **) {
17- std::vector<int > v{1 , 2 , 3 };
18- auto r = std::views::counted (std::back_inserter (v), 3 );
19- auto c = std::views::concat (r);
20- // expected-error@*:* {{}}
22+
23+ {
24+ // LWG 4082
25+ std::vector<int > v{1 , 2 , 3 };
26+ auto r = std::views::counted (std::back_inserter (v), 3 );
27+ auto c = std::views::concat (r);
28+ // expected-error@*:* {{}}
29+ }
30+
31+ {
32+ // input is not a view
33+ int x = 1 ;
34+ auto c = std::views::concat (x);
35+ // expected-error@*:* {{}}
36+ }
37+
38+ {
39+ // input is a view but has 0 size
40+ auto c = std::views::concat (NoSizeRange{});
41+ // expected-error@*:* {{}}
42+ }
43+
44+ {
45+ // inputs are non-concatable
46+ std::vector<int > v1{1 ,2 };
47+ std::vector<std::string> v2{" Hello" , " World" };
48+ auto c = std::views::concat (v1, v2);
49+ // expected-error@*:* {{}}
50+ }
2151
2252 return 0 ;
2353}
You can’t perform that action at this time.
0 commit comments