Create constraint for each parameter in template arg pack
vit
vit at vit.vit
Tue Aug 28 12:58:55 UTC 2018
On Tuesday, 28 August 2018 at 12:28:19 UTC, Andrey wrote:
> Hello,
> Let we have two variadic templates:
>> template Qwerty(Values...) {}
>> template Qaz(alias type, Data...) {}
>
> Now I want to add a constraint to "Qwerty" so that each type in
> "Values" pack must be a "Qaz" template. I don't care about
> values of "type" or "Data" in "Qaz".
> How to do it in D?
import std.meta : allSatisfy;
template Qwerty(Values...)
if(allSatisfy!(isQaz, Values)){
}
template Qaz(alias type, Data...) {}
enum isQaz(alias Q : Qaz!Args, Args...) = true;
enum isQaz(Args...) = false;
alias Foo = Qwerty!(Qaz!(i => i), Qaz!(i => i), Qaz!(i => i));
More information about the Digitalmars-d-learn
mailing list