Skip to content

Commit ff0cff1

Browse files
authored
Fix #4507: LWG-4053 Unary call to std::views::repeat does not decay the argument (#4685)
1 parent 37b793c commit ff0cff1

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

stl/inc/ranges

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1708,8 +1708,8 @@ namespace ranges {
17081708
}
17091709
};
17101710

1711-
template <class _Ty, class _Bo>
1712-
repeat_view(_Ty, _Bo) -> repeat_view<_Ty, _Bo>;
1711+
template <class _Ty, class _Bo = unreachable_sentinel_t>
1712+
repeat_view(_Ty, _Bo = _Bo()) -> repeat_view<_Ty, _Bo>;
17131713

17141714
namespace views {
17151715
struct _Repeat_fn {

tests/std/tests/P2474R2_views_repeat/test.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,16 @@ constexpr bool test() {
360360
test_iterator_arithmetic<wchar_t>();
361361
test_iterator_arithmetic<_Signed128>();
362362

363+
// GH-4507: LWG-4053 Unary call to std::views::repeat does not decay the argument
364+
{
365+
using RPV = ranges::repeat_view<const char*>;
366+
367+
static_assert(same_as<decltype(views::repeat("foo", unreachable_sentinel)), RPV>);
368+
static_assert(same_as<decltype(views::repeat(+"foo", unreachable_sentinel)), RPV>);
369+
static_assert(same_as<decltype(views::repeat("foo")), RPV>);
370+
static_assert(same_as<decltype(views::repeat(+"foo")), RPV>);
371+
}
372+
363373
return true;
364374
}
365375

0 commit comments

Comments
 (0)