Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions stl/inc/ranges
Original file line number Diff line number Diff line change
Expand Up @@ -1044,10 +1044,10 @@ namespace ranges {
struct _Iota_fn {
template <class _Ty>
_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<decay_t<_Ty>>(static_cast<_Ty&&>(_Val))))
requires requires { iota_view<decay_t<_Ty>>(static_cast<_Ty&&>(_Val)); }
{
return iota_view(static_cast<_Ty&&>(_Val));
return iota_view<decay_t<_Ty>>(static_cast<_Ty&&>(_Val));
}

template <class _Ty1, class _Ty2>
Expand Down
15 changes: 15 additions & 0 deletions tests/std/tests/P0896R4_views_iota/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ static_assert(ranges::_Advanceable<long long>);
template <class W, class B>
concept CanViewIota = requires(W w, B b) { views::iota(w, b); };

template <class W>
concept CanUnaryViewsIota = requires(W&& w) { views::iota(forward<W>(w)); };

template <class R>
concept CanSize = requires(R& r) { ranges::size(r); };

Expand Down Expand Up @@ -333,6 +336,18 @@ constexpr bool test_gh_3025() {
return true;
}

// LWG-4096 "views::iota(views::iota(0)) should be rejected"
static_assert(CanUnaryViewsIota<int>);
static_assert(CanUnaryViewsIota<const char*>);
static_assert(CanUnaryViewsIota<ranges::iterator_t<ranges::iota_view<long long>>>);
static_assert(!CanUnaryViewsIota<ranges::iota_view<int>>);
static_assert(!CanUnaryViewsIota<ranges::iota_view<const char*>>);
static_assert(!CanUnaryViewsIota<ranges::iota_view<ranges::iterator_t<ranges::iota_view<long long>>>>);
static_assert(!CanUnaryViewsIota<ranges::iota_view<int, int>>);
static_assert(!CanUnaryViewsIota<ranges::iota_view<const char*, const char*>>);
static_assert(!CanUnaryViewsIota<ranges::iota_view<ranges::iterator_t<ranges::iota_view<long long>>,
ranges::iterator_t<ranges::iota_view<long long>>>>);

int main() {
// Validate standard signed integer types
static_assert((test_integral<signed char>(), true));
Expand Down