diff --git a/stl/inc/ranges b/stl/inc/ranges index 0ba5502c16..3f8a7cc415 100644 --- a/stl/inc/ranges +++ b/stl/inc/ranges @@ -1044,10 +1044,10 @@ namespace ranges { struct _Iota_fn { template _NODISCARD _STATIC_CALL_OPERATOR constexpr auto operator()(_Ty&& _Val) _CONST_CALL_OPERATOR - noexcept(noexcept(iota_view(static_cast<_Ty&&>(_Val)))) - requires requires { iota_view(static_cast<_Ty&&>(_Val)); } + noexcept(noexcept(iota_view>(static_cast<_Ty&&>(_Val)))) + requires requires { iota_view>(static_cast<_Ty&&>(_Val)); } { - return iota_view(static_cast<_Ty&&>(_Val)); + return iota_view>(static_cast<_Ty&&>(_Val)); } template diff --git a/tests/std/tests/P0896R4_views_iota/test.cpp b/tests/std/tests/P0896R4_views_iota/test.cpp index 3e9e21759b..ef55a94ee0 100644 --- a/tests/std/tests/P0896R4_views_iota/test.cpp +++ b/tests/std/tests/P0896R4_views_iota/test.cpp @@ -19,6 +19,9 @@ static_assert(ranges::_Advanceable); template concept CanViewIota = requires(W w, B b) { views::iota(w, b); }; +template +concept CanUnaryViewsIota = requires(W&& w) { views::iota(forward(w)); }; + template concept CanSize = requires(R& r) { ranges::size(r); }; @@ -333,6 +336,18 @@ constexpr bool test_gh_3025() { return true; } +// LWG-4096 "views::iota(views::iota(0)) should be rejected" +static_assert(CanUnaryViewsIota); +static_assert(CanUnaryViewsIota); +static_assert(CanUnaryViewsIota>>); +static_assert(!CanUnaryViewsIota>); +static_assert(!CanUnaryViewsIota>); +static_assert(!CanUnaryViewsIota>>>); +static_assert(!CanUnaryViewsIota>); +static_assert(!CanUnaryViewsIota>); +static_assert(!CanUnaryViewsIota>, + ranges::iterator_t>>>); + int main() { // Validate standard signed integer types static_assert((test_integral(), true));