[RFC] Minimize functor copy in algos

Nathan Myers ncm@cantrip.org
Tue May 26 11:17:06 GMT 2026


On 5/26/26 3:23 AM, Jonathan Wakely wrote:
> On Mon, 25 May 2026 at 20:54, François Dumont <frs.dumont@gmail.com> wrote:
>>
>> In my attempt to rewrite predefined ops was also an attempt to improve
>> how the functor were passed within implementation details of the
>> different algos.
>>
>> https://gcc.gnu.org/pipermail/libstdc++/2024-October/059677.html
>>
>> As it seems to be a hot subject lately I rebased it and proposing it here.
>>
>> Even if Nathan Myers approach to work on 1 algo at a time is also a good
>> approach.
>>
>> There are still some occasions where the functor is passed by copy, when
>> building __gnu_cxx::_ops functors, I'm going to have a look at it.
> 
> Again, I don't want to change to pass-by-reference, I just want use to
> use _GLIBCXX_MOVE in the callers.
> 
> I guess I can just do it myself.

In my patch, I only use pass-by-reference to arguments of
functions declared with [[__gnu__::__always_inline__]],
so that they get direct access to the caller's copy.


More information about the Libstdc++ mailing list