std.traits

Templates which extract information about types and symbols at compile time.

tmpl AllImplicitConversionTargets arity ArrayTypeOf AssocArrayTypeOf BaseClassesTuple BaseTypeTuple BooleanTypeOf BuiltinTypeOf CharTypeOf classInstanceAlignment CommonType convertToString CopyConstness CopyTypeQualifiers DeducedParameterTypeImpl DynamicArrayTypeOf EnumMembers extractParameterStorageClassFlags FieldNameTuple Fields FloatingPointTypeOf ForeachType fqnSym fqnSym fqnType functionAttributes functionLinkage FunctionTypeOf getSymbolsByUDA getSymbolsByUDAImpl getUDAs hasAliasing hasAliasingImpl hasElaborateAssign hasFunctionAttributes hasIndirections hasNested hasObjects hasRawAliasing hasRawAliasingImpl hasRawUnsharedAliasing hasRawUnsharedAliasingImpl hasStaticMember hasUnsharedAliasing hasUnsharedAliasingImpl hasUnsharedObjects ImplicitConversionTargets IntegralTypeOf InterfacesTuple isAggregateType isAliasSeq isAutodecodableString isBlitAssignable isCallable isConvertibleToString isCovariantWith isDesiredUDA isDynamicArray isExpressions isFinal isFunction isInnerClass isInstanceOf isIntegral isNested isNestedFunction isNumeric isSafe isSomeChar isStorageClassImplicitlyConvertible isUnsafe isUnsigned Largest MemberFunctionsTuple ModifyTypePreservingTQ moduleName mostNegative NumericTypeOf OriginalType packageName ParameterDefaults ParameterIdentifierTuple Parameters ParameterStorageClassTuple Promoted QualifierOf RepresentationTypeTuple RepresentationTypeTupleImpl ReturnType Select SetFunctionAttributes SetFunctionAttributes Signed SignedTypeOf StaticArrayTypeOf StringTypeOf Unshared Unsigned UnsignedTypeOf variadicFunctionStyle

Types 37

aliasstaticMap = staticMapMeta
aliasIntegralTypeList = AliasSeq!(byte, ubyte, short, ushort, int, uint, long, ulong, CentTypeList)
aliasSignedIntTypeList = AliasSeq!(byte, short, int, long, SignedCentTypeList)
aliasUnsignedIntTypeList = AliasSeq!(ubyte, ushort, uint, ulong, UnsignedCentTypeList)
aliasFloatingPointTypeList = AliasSeq!(float, double, real)
aliasImaginaryTypeList = AliasSeq!(ifloat, idouble, ireal)
aliasComplexTypeList = AliasSeq!(cfloat, cdouble, creal)
aliasCharTypeList = AliasSeq!(char, wchar, dchar)
aliasInoutOf(T) = inout(T)

Parameters

TThe type to qualify

Returns

T with the inout qualifier added.
aliasConstOf(T) = const(T)

Parameters

TThe type to qualify

Returns

T with the const qualifier added.
aliasSharedOf(T) = shared(T)

Parameters

TThe type to qualify

Returns

T with the shared qualifier added.
aliasSharedInoutOf(T) = shared(inout(T))

Parameters

TThe type to qualify

Returns

T with the inout and shared qualifiers added.
aliasSharedConstOf(T) = shared(const(T))

Parameters

TThe type to qualify

Returns

T with the const and shared qualifiers added.
aliasSharedConstInoutOf(T) = shared(const(inout(T)))

Parameters

TThe type to qualify

Returns

T with the const, shared, and inout qualifiers added.
aliasImmutableOf(T) = immutable(T)

Parameters

TThe type to qualify

Returns

T with the immutable qualifier added.
private aliasparentOf(alias sym) = Identity!(__traits(parent, sym))
private aliasparentOf(alias sym : T!Args, alias T, Args...) = Identity!(__traits(parent, T))

Alternate name for Parameters, kept for legacy compatibility.

Get a tuple of the storage classes of a function's parameters.

Parameters

funcfunction symbol or type of function, delegate, or pointer to function

Returns

A tuple of ParameterStorageClass bits
none = 0x00These flags can be bitwise OR-ed together to represent complex storage class.
in_ = 0x01ditto
ref_ = 0x02ditto
out_ = 0x04ditto
lazy_ = 0x08ditto
scope_ = 0x10ditto
return_ = 0x20ditto

Alternate name for ParameterDefaults, kept for legacy compatibility.

Returns the FunctionAttribute mask for function func.

See Also

none = 0These flags can be bitwise OR-ed together to represent a complex attribute.
pure_ = 1 << 0ditto
nothrow_ = 1 << 1ditto
ref_ = 1 << 2ditto
property = 1 << 3ditto
trusted = 1 << 4ditto
safe = 1 << 5ditto
nogc = 1 << 6ditto
system = 1 << 7ditto
const_ = 1 << 8ditto
immutable_ = 1 << 9ditto
inout_ = 1 << 10ditto
shared_ = 1 << 11ditto
return_ = 1 << 12ditto
scope_ = 1 << 13ditto
live = 1 << 14ditto

Determines what kind of variadic parameters function has.

Parameters

funcfunction symbol or type of function, delegate, or pointer to function

Returns

enum Variadic
noFunction is not variadic.
cFunction is a C-style variadic function, which uses `core.stdc.stdarg`
dFunction is a D-style variadic function, which uses `argptr` and `arguments`.
typesafeFunction is a typesafe variadic function.

Alternate name for Fields, kept for legacy compatibility.

aliasIdentity(alias A) = A

Get a AliasSeq of all base classes of T, in decreasing order, followed by T's interfaces. TransitiveBaseTypeTuple!Object yields the empty type tuple.

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

Returns an alias to the template that T is an instance of. It will return void if a symbol without a template is given.

aliasTemplateOf(alias T) = void

ditto

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

Returns a AliasSeq of the template arguments used to instantiate T.

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

ditto

private struct__InoutWorkaroundStruct
aliasPointerTarget(T : T *) = T

Returns the target type of a pointer.

aliasisExpressionTuple = isExpressions

Alternate name for isExpressions, kept for legacy compatibility.

aliasKeyType(V : V[K], K) = K

Get the Key type of an Associative Array.

aliasValueType(V : V[K], K) = V

Get the Value type of an Associative Array.

The parameter type deduced by IFTI when an expression of type T is passed as an argument to a template function.

For all types other than pointer and slice types, DeducedParameterType!T is the same as T. For pointer and slice types, it is T with the outer-most layer of qualifiers dropped.

Functions 6

private fnFunctionAttribute extractAttribFlags(Attribs...)()
fnT rvalueOf(T)(inout __InoutWorkaroundStruct = __InoutWorkaroundStruct.init) @propertyCreates an lvalue or rvalue of type `T` for `typeof(...)` and spec/traits`) purposes. No actual value is returned.
fnT lvalueOf(T)(inout __InoutWorkaroundStruct = __InoutWorkaroundStruct.init) @property refditto
fnA select(bool cond : true, A, B)(A a, lazy B b)Select one of two functions to run via template parameter.
fnB select(bool cond : false, A, B)(lazy A a, B b)Ditto
private fnauto dip1000Test(int x)

Variables 25

enumvarisImplicitlyConvertible = is(From : To)

Is From implicitly convertible to To?

enumvarisQualifierConvertible = is(immutable From == immutable To) && is(From * : To *)

Is From spec/const3 to To?

enumvarisBoolean = __traits(isUnsigned, T) && is(T : bool)

Detect whether T is a built-in boolean type or enum of boolean base type.

enumvarisFloatingPoint = __traits(isFloating, T) && is(T : real)

Detect whether T is a built-in floating point type.

See also: spec/traits

enumvarisScalarType = __traits(isScalar, T) && is(T : real)

Detect whether T is a scalar type (a built-in numeric, character or boolean type).

See also: spec/traits

enumvarisBasicType = isScalarType!T || is(immutable T == immutable void)

Detect whether T is a basic type (scalar type or void).

enumvarisSigned = __traits(isArithmetic, T) && !__traits(isUnsigned, T) && is(T : real)

Detect whether T is a built-in signed numeric type.

enumvarisSomeString = is(immutable T == immutable C[], C) && (is(C == char) || is(C == wchar) || is(C == dchar))

Detect whether T is one of the built-in string types.

The built-in string types are Char[], where Char is any of char, wchar or dchar, with or without qualifiers.

Static arrays of characters (like char[80]) are not considered built-in string types.

enumvarisNarrowString = is(immutable T == immutable C[], C) && (is(C == char) || is(C == wchar))

Detect whether type T is a narrow string.

All arrays that use char, wchar, and their qualified versions are narrow strings. (Those include string and wstring).

enumvarisOrderingComparable = is(typeof((ref T a) => a < a ? 1 : 0))

Detects whether T is a comparable type. Basic types and structs and classes that implement opCmp are ordering comparable.

enumvarisEqualityComparable = is(typeof((ref T a) => a == a ? 1 : 0))

ditto

enumvarisStaticArray = __traits(isStaticArray, T)

Detect whether type T is a static array.

See also: spec/traits

enumvarisArray = isStaticArray!T || isDynamicArray!T

Detect whether type T is an array (static or dynamic; for associative arrays see isAssociativeArray).

enumvarisAssociativeArray = __traits(isAssociativeArray, T)

Detect whether T is an associative array type

See also: spec/traits

enumvarisBuiltinType = is(BuiltinTypeOf!T) && !isAggregateType!T

Detect whether type T is a builtin type.

enumvarisSIMDVector = is(T : __vector(V[N]), V, size_t N)

Detect whether type T is a SIMD vector type.

enumvarisPointer = is(T == U *, U)

Detect whether type T is a pointer.

enumvarisIterable = is(typeof({ foreach (elem; T.init) { } }))

Returns true if T can be iterated over using a foreach loop with a single loop variable of automatically inferred type, regardless of how the foreach loop is implemented. This includes ranges, structs/classes that define opApply with a single loop variable, and builtin dynamic, static and associative arrays.

enumvarisMutable = !is(T == const) && !is(T == immutable) && !is(T == inout)

Returns true if T is not const or immutable. Note that isMutable is true for string, or immutable(char)[], because the 'head' is mutable.

enumvarisInstanceOf = is(T == S!Args, Args...)

Returns true if T is an instance of the template S.

enumvarisFunctionPointer = is(typeof(* T) == function)

Detect whether symbol or type T is a function pointer.

enumvarisDelegate = is(typeof(T) == delegate) || is(T == delegate)

Detect whether symbol or type T is a delegate.

enumvarisSomeFunction = is(T == return) || is(typeof(T) == return) || is(typeof(& T) == return)

Detect whether symbol or type T is a function, a function pointer or a delegate.

Parameters

TThe type to check

Returns

A bool
enumvarallSameType = { static foreach (T; Ts[Ts.length > 1 .. $]) static if (!is(Ts[0] == T)) if (__ctfe) // Dodge the "statement is unreachable" warning return false; return true; }()

Returns

true iff all types Ts are the same.
enumvardip1000Enabled = is(typeof(& dip1000Test) : int function(int) @safe)

Templates 100

tmplQualifierOf(T)

Gives a template that can be used to apply the same attributes that are on the given type T. E.g. passing inout shared int will return SharedInoutOf.

Parameters

Tthe type to check qualifiers from

Returns

The qualifier template from the given type T
tmplpackageName(alias T)

Get the full package name for the given symbol.

tmplmoduleName(alias T)

Get the module name (including package) for the given symbol.

tmplfqnSym(alias T : X!A, alias X, A...)
tmplfqnSym(alias T)
Functions
string adjustIdent(string s)
tmplfqnType(T, bool alreadyConst, bool alreadyImmutable, bool alreadyShared, bool alreadyInout)
Functions
string storageClassesString(uint psc)()
string parametersTypeString(T)()
string linkageString(T)()
string functionAttributeString(T)()
string addQualifiers(string typeString, bool addConst, bool addImmutable, bool addShared, bool addInout)
tmplReturnType(alias func) if (isCallable!func)

Get the type of the return value from a function, a pointer to function, a delegate, a struct with an opCall, a pointer to a struct with an opCall, or a class with an opCall. Please note that ref is not part of a type, but the attribute of the function (see template functionAttributes).

Note

To reduce template instantiations, consider instead using typeof(() { return func(args); } ()) if the argument types are known or static if (is(typeof(func) Ret == return)) if only that basic test is needed.
tmplParameters(alias func) if (isCallable!func)

Get, as a tuple, the types of the parameters to a function, a pointer to function, a delegate, a struct with an opCall, a pointer to a struct with an opCall, or a class with an opCall.

tmplarity(alias func) if (isCallable!func && variadicFunctionStyle!func == Variadic.no)

Returns the number of arguments of function func. arity is undefined for variadic functions.

tmplParameterStorageClassTuple(alias func) if (isCallable!func)

ditto

tmplextractParameterStorageClassFlags(Attribs...)

Convert the result of spec/traits to ParameterStorageClass enums.

Parameters

AttribsThe return value of __traits(getParameterStorageClasses)

Returns

The bitwise OR of the equivalent ParameterStorageClass enums.
tmplParameterIdentifierTuple(alias func) if (isCallable!func)

Get, as a tuple, the identifiers of the parameters to a function symbol.

tmplParameterDefaults(alias func) if (isCallable!func)

Get, as a tuple, the default values of the parameters to a function symbol. If a parameter doesn't have the default value, void is returned instead.

tmplfunctionAttributes(alias func) if (isCallable!func)

ditto

tmplhasFunctionAttributes(args...) if (args.length > 0 && isCallable!(args[0]) && allSatisfy!(isSomeString, typeof(args[1 .. $])))

Checks whether a function has the given attributes attached.

Parameters

argsFunction to check, followed by a variadic number of function attributes as strings

Returns

true, if the function has the list of attributes attached and false otherwise.

See Also

tmplisSafe(alias func) if (isCallable!func)

true if func is @safe or @trusted.

tmplisUnsafe(alias func)

true if func is @system.

tmplfunctionLinkage(alias func) if (isCallable!func)

Determine the linkage attribute of the function.

Parameters

functhe function symbol, or the type of a function, delegate, or pointer to function

Returns

one of the strings "D", "C", "C++", "Windows", "Objective-C", or "System".
tmplvariadicFunctionStyle(alias func) if (isCallable!func)

ditto

tmplFunctionTypeOf(alias func) if (isCallable!func)

Get the function type from a callable object func, or from a function pointer/delegate type.

Using builtin typeof on a property function yields the types of the property value, not of the property function itself. Still, FunctionTypeOf is able to obtain function types of properties.

Note

Do not confuse function types with function pointer types; function types are

usually used for compile-time reflection purposes.

tmplSetFunctionAttributes(T, string linkage, uint attrs) if (isFunctionPointer!T || isDelegate!T)

Constructs a new function or delegate type with the same basic signature as the given one, but different attributes (including linkage).

This is especially useful for adding/removing attributes to/from types in generic code, where the actual type name cannot be spelt out.

Parameters

TThe base type.
linkageThe desired linkage of the result type.
attrsThe desired FunctionAttributes of the result type.
tmplSetFunctionAttributes(T, string linkage, uint attrs) if (is(T == function))

Ditto

tmplisInnerClass(T) if (is(T == class))

Determines whether T is a class nested inside another class and that T.outer is the implicit reference to the outer class (i.e. outer has not been used as a field or method name)

Parameters

Ttype to test

Returns

true if T is a class nested inside another, with the conditions described above;

false otherwise

tmplisNested(T) if (is(T == class) || is(T == struct) || is(T == union))

Determines whether T has its own context pointer. T must be either class, struct, or union.

See also: spec/traits

tmplhasNested(T)

Determines whether T or any of its representation types have a context pointer.

tmplFields(T)

Get as a tuple the types of the fields of a struct, class, or union. This consists of the fields that take up memory space, excluding the hidden fields like the virtual function table pointer or a context pointer for nested types. If T isn't a struct, class, interface or union returns a tuple with one element T.

History

- Returned AliasSeq!(Interface) for interfaces prior to 2.097
tmplFieldNameTuple(T)

Get as an expression tuple the names of the fields of a struct, class, or union. This consists of the fields that take up memory space, excluding the hidden fields like the virtual function table pointer or a context pointer for nested types. Inherited fields (for classes) are not included. If T isn't a struct, class, interface or union, an expression tuple with an empty string is returned.

History

- Returned AliasSeq!"" for interfaces prior to 2.097
tmplRepresentationTypeTuple(T)

Get the primitive types of the fields of a struct or class, in topological order.

tmplRepresentationTypeTupleImpl(T)
tmplhasRawAliasing(T)
tmplhasRawAliasingImpl(T)
tmplhasRawUnsharedAliasing(T)
tmplhasRawUnsharedAliasingImpl(T)
tmplhasObjects(T)
tmplhasUnsharedObjects(T)
tmplhasAliasing(T...)

Returns true if and only if T's representation includes at least one of the following:

  1. a raw pointer U* and U is not immutable;
  2. an array U[] and U is not immutable;
  3. a reference to a class or interface type C and C is not immutable.
  4. an associative array that is not immutable.
  5. a delegate.
tmplhasAliasingImpl(T)
tmplhasIndirections(T)

Returns true if and only if T's representation includes at least one of the following:

  1. a raw pointer U*;
  2. an array U[];
  3. a reference to a class type C;
  4. an associative array;
  5. a delegate;
  6. a [context pointer][isNested].
tmplhasUnsharedAliasing(T...)

Returns true if and only if T's representation includes at least one of the following:

  1. a raw pointer U* and U is not immutable or shared;
  2. an array U[] and U is not immutable or shared;
  3. a reference to a class type C and C is not immutable or shared.
  4. an associative array that is not immutable or shared.
  5. a delegate that is not shared.

tmplhasUnsharedAliasingImpl(T)
tmplhasElaborateAssign(S)

True if S or any type directly embedded in the representation of S defines an elaborate assignment. Elaborate assignments are introduced by defining opAssign(typeof(this)) or opAssign(ref typeof(this)) for a struct or when there is a compiler-generated opAssign.

A type S gets compiler-generated opAssign if it has an elaborate destructor.

Classes and unions never have elaborate assignments.

Note

Structs with (possibly nested) postblit operator(s) will have a

hidden yet elaborate compiler generated assignment operator (unless explicitly disabled).

tmplhasStaticMember(T, string member)

Whether the symbol represented by the string, member, exists and is a static member of T.

Parameters

TType containing symbol member.
memberName of symbol to test that resides in T.

Returns

true iff member exists and is static.
tmplEnumMembers(E) if (is(E == enum))

Retrieves the members of an enumerated type enum E.

Parameters

EAn enumerated type. E may have duplicated values.

Returns

Static tuple composed of the members of the enumerated type E.

The members are arranged in the same order as declared in E. The name of the enum can be found by querying the compiler for the name of the identifier, i.e. __traits(identifier, EnumMembers!MyEnum[i]). For enumerations with unique values, to can also be used.

Note

An enum can have multiple members which have the same value. If you want

to use EnumMembers to e.g. generate switch cases at compile-time, you should use the NoDuplicates template to avoid generating duplicate switch cases.

Note: Returned values are strictly typed with E. Thus, the following code does not work without the explicit cast: -------------------- enum E : int { a, b, c } int[] abc = cast(int[]) [ EnumMembers!E ]; -------------------- Cast is not necessary if the type of the variable is inferred. See the example below.

tmplBaseTypeTuple(A)

Get a AliasSeq of the base class and base interfaces of this class or interface. BaseTypeTuple!Object returns the empty type tuple.

tmplBaseClassesTuple(T) if (is(T == class))

Get a AliasSeq of all base classes of this class, in decreasing order. Interfaces are not included. BaseClassesTuple!Object yields the empty type tuple.

tmplInterfacesTuple(T)

Parameters

TThe class or interface to search.

Returns

AliasSeq of all interfaces directly or

indirectly inherited by this class or interface. Interfaces do not repeat if multiply implemented.

InterfacesTuple!Object yields an empty AliasSeq.

tmplMemberFunctionsTuple(C, string name) if (is(C == class) || is(C == interface))

Returns a tuple of non-static functions with the name name declared in the class or interface C. Covariant duplicates are shrunk into the most derived one.

tmplclassInstanceAlignment(T) if (is(T == class))

Returns class instance alignment.

See also: spec/traits

tmplCommonType(T...)

Get the type that all types can be implicitly converted to. Useful e.g. in figuring out an array type from a bunch of initializing values. Returns void if passed an empty list, or if the types have no common type.

tmplAllImplicitConversionTargets(T)

Parameters

TThe type to check

Returns

An AliasSeq with all possible target types of an implicit

conversion T.

If T is a class derived from Object, the result of

TransitiveBaseTypeTuple is returned.

If the type is not a built-in value type or a class derived from Object, an empty AliasSeq is returned.

See Also

tmplImplicitConversionTargets(T)

Parameters

TThe type to check Warning: This template is considered out-dated. It will be removed from Phobos in 2.107.0. Please use AllImplicitConversionTargets instead.

Returns

An AliasSeq with all possible target types of an implicit

conversion T.

If T is a class derived from Object, the result of

TransitiveBaseTypeTuple is returned.

If the type is not a built-in value type or a class derived from Object, an empty AliasSeq is returned.

Note

The possible targets are computed more conservatively than the

language allows, eliminating all dangerous conversions. For example, ImplicitConversionTargets!double does not include float.

See Also

tmplisBlitAssignable(T)
tmplisStorageClassImplicitlyConvertible(From, To)
tmplisCovariantWith(F, G) if (is(F == function) && is(G == function) || is(F == delegate) && is(G == delegate) || isFunctionPointer!F && isFunctionPointer!G)

Determines whether the function type F is covariant with G, i.e., functions of the type F can override ones of the type G.

tmplBooleanTypeOf(T)
tmplIntegralTypeOf(T)
tmplFloatingPointTypeOf(T)
tmplNumericTypeOf(T)
tmplUnsignedTypeOf(T)
tmplSignedTypeOf(T)
tmplCharTypeOf(T)
tmplStaticArrayTypeOf(T)
tmplDynamicArrayTypeOf(T)
tmplArrayTypeOf(T)
tmplStringTypeOf(T)
tmplAssocArrayTypeOf(T)
tmplBuiltinTypeOf(T)
tmplisIntegral(T)

Detect whether T is a built-in integral type. Integral types are byte, ubyte, short, ushort, int, uint, long, ulong, cent, ucent, and enums with an integral type as its base type.

Parameters

Ttype to test

Returns

true if T is an integral type

Note

this is not the same as __traits(isIntegral)
tmplisNumeric(T)

Detect whether T is a built-in numeric type (integral or floating point).

tmplisUnsigned(T)

Detect whether T is a built-in unsigned numeric type.

tmplisSomeChar(T)

Detect whether T is one of the built-in character types.

The built-in char types are any of char, wchar or dchar, with or without qualifiers.

tmplisConvertibleToString(T)
Warning: This trait will be deprecated as soon as it is no longer used

in Phobos. For a function parameter to safely accept a type that implicitly converts to string as a string, the conversion needs to happen at the callsite; otherwise, the conversion is done inside the function, and in many cases, that means that local memory is sliced (e.g. if a static array is passed to the function, then it's copied, and the resulting dynamic array will be a slice of a local variable). So, if the resulting string escapes the function, the string refers to invalid memory, and accessing it would mean accessing invalid memory. As such, the only safe way for a function to accept types that implicitly convert to string is for the implicit conversion to be done at the callsite, and that can only occur if the parameter is explicitly typed as an array, whereas using isConvertibleToString in a template constraint would result in the conversion being done inside the function. As such, isConvertibleToString is inherently unsafe and is going to be deprecated.

Detect whether T is a struct, static array, or enum that is implicitly convertible to a string.

tmplconvertToString(T)
tmplisAutodecodableString(T)

Detect whether type T is a string that will be autodecoded.

Given a type S that is one of:

  1. const(char)[]
  2. const(wchar)[]

Type T can be one of:

  1. S
  2. implicitly convertible to T
  3. an enum with a base type T
  4. an aggregate with a base type T

with the proviso that T cannot be a static array.

Parameters

Ttype to be tested

Returns

true if T represents a string that is subject to autodecoding

See Also:

isNarrowString
tmplisDynamicArray(T)

Detect whether type T is a dynamic array.

tmplisAggregateType(T)

Detect whether type T is an aggregate type.

tmplisInstanceOf(alias S, alias T)

ditto

tmplisExpressions(T...)

Check whether the tuple T is an expression tuple. An expression tuple only contains expressions.

See Also

tmplisCallable(alias callable)

Detect whether T is a callable object, which can be called with the function call operator (...).

Note

Implicit Function Template Instantiation is not attempted - see below.
tmplisNestedFunction(alias f)

Determines if f is a function that requires a context pointer.

Parameters

fThe type to check Returns A bool
tmplUnshared(T)

Removes shared qualifier, if any, from type T.

Note that while immutable is implicitly shared, it is unaffected by Unshared. Only explict shared is removed.

tmplModifyTypePreservingTQ(alias Modifier, T)
tmplCopyTypeQualifiers(FromType, ToType)

Copies type qualifiers from FromType to ToType.

Supported type qualifiers:

  • const
  • inout
  • immutable
  • shared
tmplCopyConstness(FromType, ToType)

Returns the type of ToType with the "constness" of FromType. A type's constness refers to whether it is const, immutable, or inout. If FromType has no constness, the returned type will be the same as ToType.

tmplForeachType(T)

Returns the inferred type of the loop variable when a variable of type T is iterated over using a foreach loop with a single loop variable and automatically inferred return type. Note that this may not be the same as std.range.ElementType!Range in the case of narrow strings, or if T has both opApply and a range interface.

tmplOriginalType(T)

Strips off all enums from type T.

tmplUnsigned(T)

Parameters

TA built in integral or vector type.

Returns

The corresponding unsigned numeric type for T with the

same type qualifiers.

If T is not a integral or vector, a compile-time error is given.

tmplLargest(T...) if (T.length >= 1)

Returns the largest type, i.e. T such that T.sizeof is the largest. If more than one type is of the same size, the leftmost argument of these in will be returned.

tmplSigned(T)

Returns the corresponding signed type for T. T must be a numeric integral type, otherwise a compile-time error occurs.

tmplmostNegative(T) if (isNumeric!T || isSomeChar!T || isBoolean!T)

Returns the most negative value of the numeric type T.

tmplPromoted(T) if (isScalarType!T)

Get the type that a scalar type T will promote to in multi-term arithmetic expressions.

tmplSelect(bool condition, T...) if (T.length == 2)

Aliases itself to T[0] if the boolean condition is true and to T[1] otherwise.

tmplgetUDAs(alias symbol, alias attribute)

Gets the matching spec/attribute from the given symbol.

If the UDA is a type, then any UDAs of the same type on the symbol will match. If the UDA is a template for a type, then any UDA which is an instantiation of that template will match. And if the UDA is a value, then any UDAs on the symbol which are equal to that value will match.

See Also

tmplisDesiredUDA(alias attribute)
tmplgetSymbolsByUDA(alias symbol, alias attribute)

Parameters

symbolThe aggregate type or module to search
attributeThe user-defined attribute to search for

Returns

All symbols within symbol that have the given UDA attribute.

Note

This is not recursive; it will not search for symbols within symbols such as

nested structs or unions.

tmplisAliasSeq(Args...)
tmplgetSymbolsByUDAImpl(alias symbol, alias attribute, names...)
tmplisFunction(alias X)

Detect whether symbol or type X is a function. This is different that finding if a symbol is callable or satisfying is(X == function), it finds specifically if the symbol represents a normal function declaration, i.e. not a delegate or a function pointer.

Returns

true if X is a function, false otherwise

See Also

Use isFunctionPointer or isDelegate for detecting those types

respectively.

tmplisFinal(alias X)

Detect whether X is a final method or class.

Returns

true if X is final, false otherwise
tmplDeducedParameterTypeImpl(T)