constraint on variadic template
Adam D. Ruppe via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Wed Dec 7 08:48:08 PST 2016
On Wednesday, 7 December 2016 at 16:35:52 UTC, Alex wrote:
> void run()
> {
> foreach(s; T)
> {
> static assert(__traits(hasMember, s, "run"));
> }
> }
Just put that in a function:
bool test(T...)() {
foreach(s; T)
if(!__traits(hasMember, s, "run"))
return false;
return true;
}
and use that as the constraint:
S(T...) if (test!T()) {}
More information about the Digitalmars-d-learn
mailing list