TakesParams

Given a function and a tuple of types, evaluates whether that function could be called with that tuple as parameters. Alias version (works on functions, not function types.)

Qualifiers like const andimmutable are skipped, which may make it a poor choice if dealing with functions that require such arguments.

It is merely syntactic sugar, using std.meta and std.traits behind the scenes.

  1. template TakesParams(alias fun, P...)
    template TakesParams (
    alias fun
    P...
    ) if (
    isSomeFunction!fun
    ) {
    static if(is(FunParams : PassedParams))
    enum TakesParams;
    static if(!(is(FunParams : PassedParams)))
    enum TakesParams;
    }
  2. template TakesParams(Fun, P...)

Members

Imports

Parameters (from std.traits)
public import std.traits : Parameters, Unqual, staticMap;
Undocumented in source.
Unqual (from std.traits)
public import std.traits : Parameters, Unqual, staticMap;
Undocumented in source.
staticMap (from std.traits)
public import std.traits : Parameters, Unqual, staticMap;
Undocumented in source.

Parameters

fun

Function to evaluate the parameters of.

P

Variadic list of types to compare fun's function parameters with.

Examples

void noParams();
bool boolParam(bool);
string stringParam(string);
float floatParam(float);

static assert(TakesParams!(noParams));
static assert(TakesParams!(boolParam, bool));
static assert(TakesParams!(stringParam, string));
static assert(TakesParams!(floatParam, float));
void foo();
void foo1(string);
void foo2(string, int);
void foo3(bool, bool, bool);

static assert(TakesParams!(foo));//, AliasSeq!()));
static assert(TakesParams!(foo1, string));
static assert(TakesParams!(foo2, string, int));
static assert(TakesParams!(foo3, bool, bool, bool));

static assert(!TakesParams!(foo, string));
static assert(!TakesParams!(foo1, string, int));
static assert(!TakesParams!(foo2, bool, bool, bool));