Thread overview | ||||||
---|---|---|---|---|---|---|
|
November 27, 2016 Given two AliasSeq (A and B) and template T, how to make AliasSeq!(T!(A[0], B[0]) ... T!(A[n], B[n])) ? | ||||
---|---|---|---|---|
| ||||
Basically the title says it all. alias A = AliasSeq!(...); alias B = AliasSeq!(...); static assert(A.length == B.length); template T(An, Bn){ ... } alias C = AliasSeq!(T!(A[0], B[0]) ... T!(A[n], B[n])); // how to make this :/ How do I actually make the sequence C? |
November 27, 2016 Re: Given two AliasSeq (A and B) and template T, how to make AliasSeq!(T!(A[0], B[0]) ... T!(A[n], B[n])) ? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Tofu Ninja | On Sunday, 27 November 2016 at 06:01:13 UTC, Tofu Ninja wrote:
> Basically the title says it all.
>
> alias A = AliasSeq!(...);
> alias B = AliasSeq!(...);
> static assert(A.length == B.length);
> template T(An, Bn){ ... }
> alias C = AliasSeq!(T!(A[0], B[0]) ... T!(A[n], B[n])); // how to make this :/
>
> How do I actually make the sequence C?
AliasSeq s auto expand. so
alias C = AliasSeq!(A,B);
|
November 27, 2016 Re: Given two AliasSeq (A and B) and template T, how to make AliasSeq!(T!(A[0], B[0]) ... T!(A[n], B[n])) ? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Tofu Ninja | On Sunday, 27 November 2016 at 06:01:13 UTC, Tofu Ninja wrote: > Basically the title says it all. > > alias A = AliasSeq!(...); > alias B = AliasSeq!(...); > static assert(A.length == B.length); > template T(An, Bn){ ... } > alias C = AliasSeq!(T!(A[0], B[0]) ... T!(A[n], B[n])); // how to make this :/ > > How do I actually make the sequence C? Whoops it would help if I read your question. You want to use Iota in conjunction with staticMap. alias pairs(int N, alias a, alias b) = AliasSeq(a[N],b[N]); alias C = staticMap!(T,staticMap(pairs,Iota!N)); |
November 27, 2016 Re: Given two AliasSeq (A and B) and template T, how to make AliasSeq!(T!(A[0], B[0]) ... T!(A[n], B[n])) ? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Nicholas Wilson | On Sunday, 27 November 2016 at 07:38:53 UTC, Nicholas Wilson wrote:
>
> Whoops it would help if I read your question.
>
> You want to use Iota in conjunction with staticMap.
> alias pairs(int N, alias a, alias b) = AliasSeq(a[N],b[N]);
> alias C = staticMap!(T,staticMap(pairs,Iota!N));
That didn't actually work, but I got it working with:
alias pairs(size_t n) = T!(A[n], B[n]);
alias C = staticMap!(pairs, Iota!(A.length));
|
Copyright © 1999-2021 by the D Language Foundation