STL icon indicating copy to clipboard operation
STL copied to clipboard

LWG-4053 Unary call to `std::views::repeat` does not decay the argument

Open StephanTLavavej opened this issue 1 year ago • 3 comments
trafficstars

LWG-4053 Unary call to std::views::repeat does not decay the argument

StephanTLavavej avatar Mar 23 '24 14:03 StephanTLavavej

Is this simple patch in <ranges> enough to fix this issue?

-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>;

leejy12 avatar Mar 25 '24 13:03 leejy12

Is this simple patch in <ranges> enough to fix this issue?

-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>;

Yes. But IIUC the resolution of LWG-4053 is only meaningful when using class template argument deduction, because LWG-4054 covers the major concern. It seems that we should test CTAD of repeat_view (test coverage is nearly completely missing), although it's not recommended for user codes to use CTAD with range adaptors.

frederick-vs-ja avatar Mar 25 '24 17:03 frederick-vs-ja

We talked about this at the weekly maintainer meeting and @barcharcraz and I agree that this LWG issue resolution is simple enough that we can just directly implement it, no specific testing needed.

StephanTLavavej avatar Mar 27 '24 21:03 StephanTLavavej