Is there a way to get the address of the function that would be used in Implicit Function Template Instantiation?

Nathan S. no.public.email at example.com
Wed Jun 27 22:59:03 UTC 2018


On Wednesday, 27 June 2018 at 22:39:26 UTC, Jonathan M Davis 
wrote:
> You could explicitly instantiate the function template and then 
> take its address.

Explicitly instantiating the template can result in a function 
that may be behaviorally identical but have a different address.

https://run.dlang.io/is/E9WroB
---
auto foo(T)(const T x) { return x; }

void main()
{
     const int a;
     assert(&foo!int !is &foo!(const int)); // The addresses are 
different.
     foo(a); // If I look in the object file I can see this uses 
foo!int.
     assert(&foo!(typeof(a)) !is &foo!int);
}
---


More information about the Digitalmars-d-learn mailing list