www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Higher Order Type Tuple Predicate

reply =?UTF-8?B?Ik5vcmRsw7Z3Ig==?= <per.nordlow gmail.com> writes:
Is there some trait in Phobos to check if each element of a type 
tuple fulfil a type predicate?

I want this in a variadic function limiter to assert that all its 
arguments function fulfils a predicate.

Something like:

void f(T...)(T args) if (All!(T,SomePredicate))
{
...
}
Feb 13 2014
parent "simendsjo" <simendsjo gmail.com> writes:
On Thursday, 13 February 2014 at 11:25:09 UTC, Nordlöw wrote:
 Is there some trait in Phobos to check if each element of a 
 type tuple fulfil a type predicate?

 I want this in a variadic function limiter to assert that all 
 its arguments function fulfils a predicate.

 Something like:

 void f(T...)(T args) if (All!(T,SomePredicate))
 {
 ...
 }
You probably need std.typetuple:
Feb 13 2014