[PATCHv2] libstdc++: Add NTTP bind_front, -back, not_fn (P2714) [PR119744]
Tomasz Kaminski
tkaminsk@redhat.com
Mon Jul 21 10:34:05 GMT 2025
There is also one very subtle difference, the current wording requires
argument to
be passed as xvalues, i.e. it forces temporary materialization and move.
What I mean
if you have:
struct Call {};
struct F{
void operator()(M m);
} f;
Then:
f(M{}); // will construct M directly into parameter,
bind_front(f)(M{}); // is required to create temporary, and then move from
it.
Regards,
Tomasz
On Mon, Jul 21, 2025 at 12:27 PM Tomasz Kaminski <tkaminsk@redhat.com>
wrote:
>
>
> On Sat, Jul 19, 2025 at 3:25 AM Nathan Myers <ncm@cantrip.org> wrote:
>
>> On 7/18/25 07:21, Tomasz Kaminski wrote:
>> > And then having in bind_front()
>> > if constexpr (sizeof(_BoundsArgs) == 0)
>> > return _Fn_t<__fn>();
>>
>> Is the above better than just
>>
>> if constexpr (sizeof(_BoundArgs) == 0)
>> return __fn;
>>
> Yes, if __fn has runtime state (imagine function pointer) then:
> * it size will be greater than zero, while _Fn_t is empty - this affects
> function wrappers
> * when as callback (for example comparator to std::sort), unless the
> algorithm call is inlined,
> we will get runtime dispatch via pointer, for _Fn_t the pointer value is
> embedded in the type.
> Regards,
> Tomasz
>
>>
>> ?
>>
>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://gcc.gnu.org/pipermail/libstdc++/attachments/20250721/f7c2147f/attachment.htm>
More information about the Libstdc++
mailing list