aliasing functions with function arguments as well ??

james.p.leblanc james.p.leblanc at gmail.com
Fri Aug 13 15:04:48 UTC 2021


Dear All,

How does one use 'alias' to incorporate function arguments as 
well?

(I believe this is possible, from some of the examples of 
aliasSeq, and
the traits.Parameters documentation.  However, I was unable to 
come up
with anything that works.)

What should replace the question marks (???) below?

>double bar( int a, double x){
>   return a*x:
>}

>template foo(T){
>   static if ( is(T==int) ){
>      alias ??? = ???
>   }
>   else{
>      alias ??? = ???
>   }
>}
>
>// when T == int, I desire the aliasing to produce resulting 
>code:
>foo( int a) = bar( int a, 42.33);
>
>// when T == double, I desire:
>foo( double x) = bar( 7, x);


Thanks kindly for any information!
James

PS I am aware of the "struct holding a function allowing multiple 
dispatch concept"
... while that would fit quite okay here in my simple example, it 
isn't appropriate
for my real use.



More information about the Digitalmars-d-learn mailing list