__invoke_impl - - Dereference the pointer
Tomasz Kaminski
tkaminsk@redhat.com
Mon Jan 19 13:13:45 GMT 2026
The current implementation of std::invoke(f, t) support situation when t is
smart_pointer (shared_ptr, unique_ptr, but also anything with operator*),
and this is required per standard.
As none of standard defined smart pointers (and I except user defined ones)
overloads operator->*, your proposed alternative will break their support,
and be non-confiroming.
Regard,
Tomasz
On Mon, Jan 19, 2026 at 1:57 PM Frederick Virchanza Gotham <
cauldwell.thomas@gmail.com> wrote:
> Inside the file "bits/invoke.h", I see
>
> template<typename _Res, typename _MemFun, typename _Tp, typename...
> _Args>
> constexpr _Res
> __invoke_impl(__invoke_memfun_deref, _MemFun&& __f, _Tp&& __t,
> _Args&&... __args)
> {
> return
> ((*std::forward<_Tp>(__t)).*__f)(std::forward<_Args>(__args)...);
> }
>
> See how the pointer is dereferenced:
>
> ((*std::forward<_Tp>(__t)).*__f)
>
> I am implementing my chimeric_ptr, and it would be very easy to
> implement if I could just change the above line to:
>
> (std::forward<_Tp>(__t)->*__f)
>
> I can't think of any problems that might arise from me making this
> change, but I just though I'd ask here just in case someone can think
> of something.
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://gcc.gnu.org/pipermail/libstdc++/attachments/20260119/ac5302be/attachment.htm>
More information about the Libstdc++
mailing list