File tree Expand file tree Collapse file tree 2 files changed +32
-1
lines changed
tests/std/tests/P1206R7_ranges_to_misc Expand file tree Collapse file tree 2 files changed +32
-1
lines changed Original file line number Diff line number Diff line change @@ -1121,7 +1121,11 @@ namespace ranges {
11211121 if constexpr (_Sized_and_reservable<_Rng, _Container>) {
11221122 _Cont.reserve (static_cast <range_size_t <_Container>>(_RANGES size (_Range)));
11231123 }
1124- for (auto && _Elem : _Range) {
1124+
1125+ auto _Iter = _RANGES begin (_Range);
1126+ const auto _Sent = _RANGES end (_Range);
1127+ for (; _Iter != _Sent; ++_Iter) {
1128+ auto && _Elem = *_Iter;
11251129 using _ElemTy = decltype (_Elem);
11261130 if constexpr (_Can_emplace_back<_Container, _ElemTy>) {
11271131 _Cont.emplace_back (_STD forward<_ElemTy>(_Elem));
Original file line number Diff line number Diff line change @@ -336,6 +336,30 @@ constexpr bool test_lwg4016() {
336336 return true ;
337337}
338338
339+ struct adl_only_range {
340+ static constexpr int numbers[2 ]{42 , 1729 };
341+
342+ void begin () const = delete;
343+ void end () const = delete;
344+
345+ friend constexpr const int * begin (const adl_only_range&) {
346+ return ranges::begin (numbers);
347+ }
348+ friend constexpr const int * end (const adl_only_range&) {
349+ return ranges::end (numbers);
350+ }
351+ };
352+
353+ constexpr bool test_lwg4016_regression () {
354+ using vec = restricted_vector<restriction_kind::push_back, int >;
355+
356+ ranges::contiguous_range auto r = adl_only_range{};
357+ auto v = r | ranges::to<vec>();
358+ assert (ranges::equal (v, adl_only_range::numbers));
359+
360+ return true ;
361+ }
362+
339363int main () {
340364 test_reservable ();
341365 static_assert (test_reservable ());
@@ -356,4 +380,7 @@ int main() {
356380
357381 test_lwg4016 ();
358382 static_assert (test_lwg4016 ());
383+
384+ test_lwg4016_regression ();
385+ static_assert (test_lwg4016_regression ());
359386}
You can’t perform that action at this time.
0 commit comments