constraint on variadic template
Gary Willoughby via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Wed Dec 7 09:08:09 PST 2016
On Wednesday, 7 December 2016 at 16:35:52 UTC, Alex wrote:
> mixin template S(T...)
> {
> void run()
> {
> foreach(s; T)
> {
> static assert(__traits(hasMember, s, "run"));
> }
> }
> }
>
> How to formulate the check inside the foreach as a template
> constraint with
> mixin template S(T...) if(???)
Will some like this work?
import std.range.primitives;
mixin template S(T...) if(__traits(hasMember,
ElementType!(T), "run"))
{
...
}
https://dlang.org/phobos/std_range_primitives.html#ElementType
More information about the Digitalmars-d-learn
mailing list