std.traits
Templates with which to extract information about
types at compile time.
- template ReturnType(alias dg)
template ReturnType(dg)
- Get the type of the return value from a function,
a pointer to function, or a delegate.
Example:
import std.traits;
int foo();
ReturnType!(foo) x;
- template ParameterTypeTuple(alias dg)
template ParameterTypeTuple(dg)
- Get the types of the paramters to a function,
a pointer to function, or a delegate as a tuple.
Example:
import std.traits;
int foo(int, long);
void bar(ParameterTypeTuple!(foo)); void abc(ParameterTypeTuple!(foo)[1]);
- template FieldTypeTuple(S)
- Get the types of the fields of a struct or class.
This consists of the fields that take up memory space,
excluding the hidden fields like the virtual function
table pointer.
- template BaseTypeTuple(A)
- Get a TypeTuple of the base class and base interfaces of
this class or interface.
Example:
import std.traits, std.typetuple, std.stdio;
interface I { }
class A { }
class B : A, I { }
void main()
{
alias BaseTypeTuple!(B) TL;
writefln(typeid(TL)); }
- template isStaticArray(T)
- Detect whether type T is a static array.
- template isExpressionTuple(T...)
- Tells whether the tuple T is an expression tuple.