how to do template constraints with variadic templates ?

Flaze07 christianseiji.cs at gmail.com
Sun Jul 8 00:46:13 UTC 2018


I want to force the variadic templates's type to be of certain 
types, I thought doing this would work
auto sum( A... )( A a ) if( isIntegral!( typeid( a[ 0 ] ) ) )
{
     int temp;
     foreach( t ; a )
     {
         temp += t;
     }
     return temp;
}
but it gives out error
( note : I want all the parameter to be integral, i.e sum( 1, 2, 
5, "error" ); //error


More information about the Digitalmars-d-learn mailing list