https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118413

Patrick Palka <ppalka at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ppalka at gcc dot gnu.org

--- Comment #4 from Patrick Palka <ppalka at gcc dot gnu.org> ---
I think the definition of __can_transform_view is correct/idiomatic, we must be
passing the wrong types to it.

/opt/compiler-explorer/gcc-trunk-20250111/include/c++/15.0.0/ranges:2247:10:  
required for the satisfaction of '__can_transform_view<_Range, _Fp>' [with
_Range = std::ranges::iota_view<int, int>; _Fp = const move_only_fn&]
/opt/compiler-explorer/gcc-trunk-20250111/include/c++/15.0.0/ranges:2248:6:  
in requirements  [with _Range = std::ranges::iota_view<int, int>; _Fp = const
move_only_fn&]
/opt/compiler-explorer/gcc-trunk-20250111/include/c++/15.0.0/ranges:2248:24:
note: the required expression 'transform_view<...auto...>(declval<_Range>(),
declval<_Fp>())' is invalid, because


It's failing because we're incorrectly passing _Fp = const move_only_fn& to
__can_transform_view rather than _Fp = move_only_fn&&.

And seems that's because for adaptors that take a function object, we currently
always enable the _S_has_simple_extra_args optimization (which simplifies the
overload set of partially applied range adaptors and always forwards the saved
arguments by const reference), which was fine when functions were required to
be copyable but after P2494R2 we need to disable this optimization for
non-copyable functions.

Reply via email to