Thread overview | |||||
---|---|---|---|---|---|
|
August 14, 2021 Looping over Template Types ... possible? | ||||
---|---|---|---|---|
| ||||
Good Evening/Day, Suppose I have a number of function templates that each take two types, say S and T. I would like to exercise my routines over the combinations of types: set of all S: ( double[], float[], Complex!double[], Complex!float[]) set of all T: ( double, float) Is something along the line of the following sketch possible? foreach( s in S){ foreach( t in T){ foo!(S,T)( T x, S y); biz!(S,T)( T x, S y); } } I have done some searching for hints about this, but I perhaps my search terms are not very good. All hint and pointers thankfully received. Best Regards, James |
August 14, 2021 Re: Looping over Template Types ... possible? | ||||
---|---|---|---|---|
| ||||
Posted in reply to james.p.leblanc | On Saturday, 14 August 2021 at 20:07:21 UTC, james.p.leblanc wrote:
> Good Evening/Day,
>
> Suppose I have a number of function templates that each take
> two types, say S and T.
>
> I would like to exercise my routines over the combinations
> of types:
>
> set of all S: ( double[], float[], Complex!double[], Complex!float[])
> set of all T: ( double, float)
>
> Is something along the line of the following sketch possible?
>
> foreach( s in S){
> foreach( t in T){
>
> foo!(S,T)( T x, S y);
> biz!(S,T)( T x, S y);
>
> }
> }
>
> I have done some searching for hints about this, but I perhaps
> my search terms are not very good.
>
> All hint and pointers thankfully received.
>
> Best Regards,
> James
it is possible
look for `AliasSeq`
in `std.meta`
foreach(T; AliasSeq!(float, double))
{
...
}
|
August 14, 2021 Re: Looping over Template Types ... possible? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Stefan Koch | On Saturday, 14 August 2021 at 20:20:01 UTC, Stefan Koch wrote: > On Saturday, 14 August 2021 at 20:07:21 UTC, james.p.leblanc wrote: mes > > it is possible > > look for `AliasSeq` > in `std.meta` > > foreach(T; AliasSeq!(float, double)) > { > ... > } Stefan, Thanks very much for your help here ... I had not understood that AliasSeq worked in this manner. I definitely need read the AliasSeq and try to understand how to use this. Best Regards, James |
Copyright © 1999-2021 by the D Language Foundation