Variadic template parameters T... bounding

Daniel Kozak via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Feb 2 05:47:23 PST 2016


On Tuesday, 2 February 2016 at 13:20:33 UTC, Voitech wrote:
> Hi, Is it possible to bound T... in template with some type ? 
> For single Parameter declaration it can be done by T:SomeType 
> but variadics does not seems to have that possibility ?
> Cheers

import std.stdio;
import std.meta: allSatisfy;
import std.traits;

void some(T...)(T Args) if (allSatisfy!(isIntegral,T)) {
     writeln(Args);
}

void main()
{
     some(1);
     some(1,2,3);
     some(1,2,3.0); // error
}


More information about the Digitalmars-d-learn mailing list