Skip to content

Commit 288955a

Browse files
fix test
1 parent 7b58c0e commit 288955a

File tree

2 files changed

+36
-6
lines changed

2 files changed

+36
-6
lines changed

libcxx/include/__ranges/concat_view.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ concept __concat_is_bidirectional =
111111
(__all_bidirectional<_Const, _Rs...>) && (__all_common_ignore_last<_Const, _Rs...>::value);
112112

113113
template <input_range... _Views>
114-
requires(view<_Views> && ...) && (sizeof...(_Views) > 0) && __concatable<_Views...>
114+
requires((view<_Views> && ...) && (sizeof...(_Views) > 0) && __concatable<_Views...>)
115115
class 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

212212
template <input_range... _Views>
213-
requires(view<_Views> && ...) && (sizeof...(_Views) > 0) && __concatable<_Views...>
213+
requires((view<_Views> && ...) && (sizeof...(_Views) > 0) && __concatable<_Views...>)
214214
template <bool _Const>
215215
class concat_view<_Views...>::__iterator : public __concat_view_iterator_category<_Const, _Views...> {
216216
public:

libcxx/test/std/ranges/range.adaptors/range.concat/ctor.verify.cpp

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,44 @@
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+
1621
int 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
}

0 commit comments

Comments
 (0)