Date: Wed, 10 Jul 2024 23:40:33 +0530
@organicoman Currently there is no way im the standard to get the function
template arguments in your example afaik.
On Wed, 10 Jul 2024, 23:08 organicoman via Std-Proposals <
std-proposals_at_[hidden] wrote:
>
> >> template<void(*)(int)>
> >> struct A { // impl };
>
> >You can't. A function pointer points to a >function. You can't have a
> >pointer to a function template. So, at the >point when A is instantiated,
> >the function pointer must be either null or >point to a function, whether
> >it was generated as a result of a function >template instantiation or was
> >never a template to begin with.
>
> Yet a function pointer is compile time constant, that means we can examine
> its properties at compile time. And the template arguments are among these
> properties.
> This is related to type erasure.
> I think the compiler should allow a way to access the template arguments
> of a function pointer.
> Because when we pass a function pointer generated from a function template
> usually we do
>
> A<foo<T1,T2>> a;
>
> Which is mandatory to avoid overload ambiguity.
>
> And at this point, we see clearly the template arguments, and i don't see
> why the compiler can't see them!
>
>
>
> Sent from my Galaxy
>
>
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>
template arguments in your example afaik.
On Wed, 10 Jul 2024, 23:08 organicoman via Std-Proposals <
std-proposals_at_[hidden] wrote:
>
> >> template<void(*)(int)>
> >> struct A { // impl };
>
> >You can't. A function pointer points to a >function. You can't have a
> >pointer to a function template. So, at the >point when A is instantiated,
> >the function pointer must be either null or >point to a function, whether
> >it was generated as a result of a function >template instantiation or was
> >never a template to begin with.
>
> Yet a function pointer is compile time constant, that means we can examine
> its properties at compile time. And the template arguments are among these
> properties.
> This is related to type erasure.
> I think the compiler should allow a way to access the template arguments
> of a function pointer.
> Because when we pass a function pointer generated from a function template
> usually we do
>
> A<foo<T1,T2>> a;
>
> Which is mandatory to avoid overload ambiguity.
>
> And at this point, we see clearly the template arguments, and i don't see
> why the compiler can't see them!
>
>
>
> Sent from my Galaxy
>
>
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>
Received on 2024-07-10 18:10:47