tanya.meta.trait

Type traits.

Templates in this module are used to obtain type information at compile time.

Members

Aliases

TemplateArgsOf
alias TemplateArgsOf(alias T : Base!Args, alias Base, Args...) = Args

Returns template parameters of T.

TemplateOf
alias TemplateOf(alias T : Base!Args, alias Base, Args...) = Base

Determines the template T is an instance of.

evalUDA
alias evalUDA(alias T) = T
alias evalUDA(T) = Alias!(T())

If T is a type, constructs its default value, otherwise $(D_PSYMBOL evalUDA) aliases itself to T.

getUDAs
alias getUDAs(alias symbol) = AliasSeq!(__traits(getAttributes, symbol))

Enums

FunctionAttribute
enum FunctionAttribute

Attributes can be attached to a function.

Templates

BaseClassesTuple
template BaseClassesTuple(T)

Returns all the base classes of T, the direct parent class comes first, $(D_PSYMBOL Object) ist the last one.

BaseTypeTuple
template BaseTypeTuple(T)

Returns a tuple of base classes and interfaces of T.

EnumMembers
template EnumMembers(T)

Returns all members of $(D_KEYWORD enum) T.

Fields
template Fields(T)

Returns the types of all members of T.

FunctionTypeOf
template FunctionTypeOf(F...)

Determines the type of the callable F.

InterfacesTuple
template InterfacesTuple(T)

Returns all the interfaces T inherits from.

ParameterDefaults
template ParameterDefaults(F...)

Returns a tuple with default values of the parameters to F.

ParameterIdentifierTuple
template ParameterIdentifierTuple(F...)

Returns a string array with all parameter names of a function.

Parameters
template Parameters(F...)

Returns a tuple with parameter types of a function.

ReturnType
template ReturnType(F...)

Determines the return type of the callable F.

TransitiveBaseTypeTuple
template TransitiveBaseTypeTuple(T)

Returns a tuple of all base classes and interfaces of T.

allSameType
template allSameType(Types...)

Determines whether all Types are the same.

classInstanceAlignment
template classInstanceAlignment(T)

Different than T.alignof, which is the same for all class types, $(D_PSYMBOL classInstanceOf) determines the alignment of the class instance and not of its reference.

functionAttributes
template functionAttributes(F...)

Retrieves the attributes of the function F.

getUDAs
template getUDAs(alias symbol, alias attr)

Returns a compile-time tuple of user-defined attributes (UDA) attached to symbol.

hasElaborateAssign
template hasElaborateAssign(T)

Determines whether T has an elaborate assign.

hasElaborateCopyConstructor
template hasElaborateCopyConstructor(T)

Determines whether T has an elaborate postblit constructor.

hasElaborateDestructor
template hasElaborateDestructor(T)

Determines whether T has an elaborate destructor.

hasFunctionAttributes
template hasFunctionAttributes(Args...)

Determines whether a function has attribute.

hasStaticMember
template hasStaticMember(T, string member)

Determines whether the type T has a static method named member.

hasUDA
template hasUDA(alias symbol, alias attr)

Determines whether symbol has user-defined attribute attr attached to it.

ifTestable
template ifTestable(T, alias pred = a => a)

Tests whether pred(T) can be used as condition in an $(D_KEYWORD if)-statement or a ternary operator.

isArray
template isArray(T)

Determines whether T is an array type (dynamic or static, but not an associative one).

isAssignable
template isAssignable(Lhs, Rhs = Lhs)

Tests whether a value of type Rhs can be assigned to a variable of type Lhs.

isAssociativeArray
template isAssociativeArray(T)

Determines whether T is an associative array type.

isCallable
template isCallable(F...)
isDelegate
template isDelegate(F...)

Delegate stores the function pointer and function context.

isExpressions
template isExpressions(Args...)

Tells whether Args contains only expressions.

isFunction
template isFunction(F...)

$(D_PSYMBOL isFunction) returns $(D_KEYWORD true) only for plain functions, not function pointers or delegates. Use $(D_PSYMBOL isFunctionPointer) or $(D_PSYMBOL isDelegate) to detect them or $(D_PSYMBOL isSomeFunction) for detecting a function of any type.

isFunctionPointer
template isFunctionPointer(F...)

Function pointer is a pointer to a function. So a simple function is not a function pointer, but getting the address of such function returns a function pointer.

isInnerClass
template isInnerClass(T)

Tests whether T is an inner class, i.e. a class nested inside another class.

isInstanceOf
template isInstanceOf(alias T, alias I)
Undocumented in source.
isMutable
template isMutable(T)

Determines whether T is mutable, i.e. has one of the following qualifiers or a combination of them:

isNested
template isNested(T)

Determines whether T is a nested type, i.e. $(D_KEYWORD class), $(D_KEYWORD struct) or $(D_KEYWORD union), which internally stores a context pointer.

isPointer
template isPointer(T)

Determines whether T is a pointer type.

isSomeFunction
template isSomeFunction(F...)
isStaticArray
template isStaticArray(T)

Determines whether T is a static array type.

mostNegative
template mostNegative(T)

Returns the minimum value of type T. In contrast to T.min this template works with floating point and complex types as well.

stateSize
template stateSize(T)

Returns the size in bytes of the state that needs to be allocated to hold an object of type T.

Variables

hasMember
enum bool hasMember(T, string member);

Determines whether T defines a symbol member.

isAbstractClass
enum bool isAbstractClass(T);

Determines whether T is an abstract class.

isAbstractFunction
enum bool isAbstractFunction(alias F);

Determines whether T is an abstract method.

isAggregateType
enum bool isAggregateType(T);

Determines whether T is an aggregate type.

isBasicType
enum bool isBasicType(T);

Determines whether T is a basic type.

isBoolean
enum bool isBoolean(T);

Determines whether T is a boolean type, i.e. $(D_KEYWORD bool).

isBuiltinType
enum bool isBuiltinType(T);

Determines whether T is a built-in type.

isComplex
enum bool isComplex(T);

Determines whether T is a complex type.

isCopyable
enum bool isCopyable(T);

Determines whether the type T is copyable.

isDynamicArray
enum bool isDynamicArray(T);

Determines whether T is a dynamic array type.

isEqualityComparable
enum bool isEqualityComparable(T);

Determines whether values of type T can be compared for equality, i.e. using == or != binary operators.

isFinalClass
enum bool isFinalClass(T);

Determines whether T is a final class.

isFinalFunction
enum bool isFinalFunction(alias F);

Determines whether T is a final method.

isFloatingPoint
enum bool isFloatingPoint(T);

Determines whether T is a floating point type.

isImplicitlyConvertible
enum bool isImplicitlyConvertible(From, To);

Checks whether From is implicitly (without explicit $(D_KEYWORD cast)) to To.

isInstanceOf
enum bool isInstanceOf(alias T, I);

Tests whether I is an instance of template T.

isIntegral
enum bool isIntegral(T);

Determines whether T is an integral type.

isNarrowString
enum bool isNarrowString(T);

Determines whether T is a narrow string, i.e. consists of $(D_KEYWORD char) or $(D_KEYWORD wchar).

isNestedFunction
enum bool isNestedFunction(alias F);

Determines whether T is a nested function.

isNumeric
enum bool isNumeric(T);

Determines whether T is a numeric (floating point, integral or complex) type. *

isOrderingComparable
enum bool isOrderingComparable(T);

Determines whether values of type T can be compared for ordering, i.e. using >, >=, < or <= binary operators.

isPolymorphicType
enum bool isPolymorphicType(T);

Determines whether T is a polymorphic type, i.e. a $(D_KEYWORD class) or an $(D_KEYWORD interface).

isScalarType
enum bool isScalarType(T);

Determines whether T is a scalar type.

isSigned
enum bool isSigned(T);

Determines whether T is a signed numeric type.

isSomeChar
enum bool isSomeChar(T);

Determines whether T is a character type.

isSomeString
enum bool isSomeString(T);

Determines whether T is a string, i.e. consists of $(D_KEYWORD char), $(D_KEYWORD wchar) or $(D_KEYWORD dchar).

isType
enum bool isType(alias T);
enum bool isType(T);

Checks whether T is a type, same as is(T) does.

isTypeTuple
enum bool isTypeTuple(Args...);

Determines whether Args contains only types.

isUnsigned
enum bool isUnsigned(T);

Determines whether T is an unsigned numeric type.

isWideString
enum bool isWideString(T);

Determines whether T is a wide string, i.e. consists of $(D_KEYWORD dchar).

mangledName
enum string mangledName(T);

Returns the mangled name of the symbol T.

mangledName
enum string mangledName(alias T);

Meta