Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #4507: LWG-4053 Unary call to std::views::repeat does not decay the argument #4685

Merged
merged 3 commits into from
May 23, 2024
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
4 changes: 2 additions & 2 deletions stl/inc/ranges
Original file line number Diff line number Diff line change
Expand Up @@ -1708,8 +1708,8 @@ namespace ranges {
}
};

template <class _Ty, class _Bo>
repeat_view(_Ty, _Bo) -> repeat_view<_Ty, _Bo>;
template <class _Ty, class _Bo = unreachable_sentinel_t>
repeat_view(_Ty, _Bo = _Bo()) -> repeat_view<_Ty, _Bo>;

namespace views {
struct _Repeat_fn {
Expand Down
10 changes: 10 additions & 0 deletions tests/std/tests/P2474R2_views_repeat/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,16 @@ constexpr bool test() {
test_iterator_arithmetic<wchar_t>();
test_iterator_arithmetic<_Signed128>();

// GH-4507: LWG-4053 Unary call to std::views::repeat does not decay the argument
{
using RPV = ranges::repeat_view<const char*>;

static_assert(same_as<decltype(views::repeat("foo", unreachable_sentinel)), RPV>);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, these static_assert's actually tested the changes in LWG-4054, not LWG-4053 only. I'll fix this in a new PR soon.

static_assert(same_as<decltype(views::repeat(+"foo", unreachable_sentinel)), RPV>);
static_assert(same_as<decltype(views::repeat("foo")), RPV>);
static_assert(same_as<decltype(views::repeat(+"foo")), RPV>);
}

return true;
}

Expand Down