Skip to content

Commit e66aca5

Browse files
committed
[libc++][ranges] LWG4096: views::iota(views::iota(0)) should be rejected
Fixes: #105352
1 parent ef98e24 commit e66aca5

File tree

3 files changed

+32
-2
lines changed

3 files changed

+32
-2
lines changed

libcxx/docs/Status/Cxx2cIssues.csv

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@
7171
"`LWG4079 <https://wg21.link/LWG4079>`__","Missing Preconditions in ``concat_view::iterator``\`s conversion constructor","2024-06 (St. Louis)","","",""
7272
"`LWG4082 <https://wg21.link/LWG4082>`__","``views::concat(r)`` is well-formed when ``r`` is an ``output_range``","2024-06 (St. Louis)","","",""
7373
"`LWG4083 <https://wg21.link/LWG4083>`__","``views::as_rvalue`` should reject non-input ranges","2024-06 (St. Louis)","","",""
74-
"`LWG4096 <https://wg21.link/LWG4096>`__","``views::iota(views::iota(0))`` should be rejected","2024-06 (St. Louis)","","",""
74+
"`LWG4096 <https://wg21.link/LWG4096>`__","``views::iota(views::iota(0))`` should be rejected","2024-06 (St. Louis)","|Complete|","22",""
7575
"`LWG4098 <https://wg21.link/LWG4098>`__","``views::adjacent<0>`` should reject non-forward ranges","2024-06 (St. Louis)","","",""
7676
"`LWG4105 <https://wg21.link/LWG4105>`__","``ranges::ends_with``\`s Returns misses difference casting","2024-06 (St. Louis)","","",""
7777
"`LWG4106 <https://wg21.link/LWG4106>`__","``basic_format_args`` should not be default-constructible","2024-06 (St. Louis)","|Complete|","19",""

libcxx/include/__ranges/iota_view.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include <__ranges/movable_box.h>
3131
#include <__ranges/view_interface.h>
3232
#include <__type_traits/conditional.h>
33+
#include <__type_traits/decay.h>
3334
#include <__type_traits/is_nothrow_constructible.h>
3435
#include <__type_traits/make_unsigned.h>
3536
#include <__type_traits/type_identity.h>
@@ -377,7 +378,7 @@ struct __fn {
377378
_LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Start&& __start) const
378379
noexcept(noexcept(ranges::iota_view(std::forward<_Start>(__start))))
379380
-> decltype(ranges::iota_view(std::forward<_Start>(__start))) {
380-
return ranges::iota_view(std::forward<_Start>(__start));
381+
return ranges::iota_view<decay_t<_Start>>(std::forward<_Start>(__start));
381382
}
382383

383384
template <class _Start, class _BoundSentinel>
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
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++20
10+
11+
// views::iota
12+
13+
#include <ranges>
14+
15+
#include "types.h"
16+
17+
void test() {
18+
// LWG4096
19+
{
20+
[[maybe_unused]] auto i1 = std::views::iota(0); // OK
21+
[[maybe_unused]] auto i2 = std::views::iota(std::views::iota(0));
22+
// expected-error-re@*:* {{constraints not satisfied for class template 'iota_view'{{.*}}}}
23+
}
24+
{
25+
[[maybe_unused]] auto i1 = std::views::iota(SomeInt(0)); // OK
26+
[[maybe_unused]] auto i2 = std::views::iota(std::views::iota(SomeInt(0)));
27+
//expected-error-re@*:* {{constraints not satisfied for class template 'iota_view'{{.*}}}}
28+
}
29+
}

0 commit comments

Comments
 (0)