isVariadicArgsOf

Ensures that the given variadic arguments are all of the given type

bool
isVariadicArgsOf
(
T_should
VarArgs...
)
()

Return Value

Type: bool

true if so, false otherwise

Examples

A function is implemented which wants to ensure its variadic arguments are all of the same type.

This tests out two positive cases and one failing case.

enum SomeType
{
    UM,
    DOIS,
    TRES,
    QUATRO
}

void myFunc(T...)(T, string somethingElse)
if(isVariadicArgsOf!(SomeType, T)())
{

}
static assert(__traits(compiles, myFunc(SomeType.UM, SomeType.DOIS, "Halo")));

static assert(__traits(compiles, myFunc(SomeType.UM, "Halo")));
static assert(!__traits(compiles, myFunc(1, "Halo")));

Meta