generic function instance without call

user1234 user1234 at 12.de
Wed Apr 27 16:03:32 UTC 2022


On Wednesday, 27 April 2022 at 15:23:26 UTC, vit wrote:
> Hi, is it possible to get address of generic function instance 
> for specified arguments without calling the function?
>
> Example:
>
>
> ```d
>
> auto foo(alias fn, Args...)(auto ref Args args){
>     ///return function/delegate type of `fn` for arguments 
> `args`
> }
>
> void main(){
>
>     long x;
>
>     auto fn = foo!((a, b) => true)(new int(42), x);
>
>     static assert(is(typeof(fn) == bool function(int*, scope 
> ref long)@safe pure nothrow @nogc ));
> }
>
> ```

yeah sure; declare an alias that (fully) specialize the generic 
func and take the address using the alias Identifier.


More information about the Digitalmars-d-learn mailing list