std.traits
Templates with which to extract information about types at compile time.
Copyright:
Public Domain
Templates
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
)
)
;
// prints: (A,I)
}
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.
isExpressionTuple(T)
Tells whether the tuple T is an expression tuple.
Fields
const
isExpressionTuple
:
bool
isStaticArray(T)
Detect whether type T is a static array.
Fields
const
isStaticArray
:
bool
isStaticArray_impl(T)
Fields
const
inst
:
int
const
res
:
bool
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
)
)
;
// declares void bar(int, long);
void
abc
(
ParameterTypeTuple
!
(
foo
)
[
1
]
)
;
// declares void abc(long);
Aliases
ParameterTypeTuple
:
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
;
// x is declared as int
Aliases
ReturnType
: