iz

Iz is a helper template that allows you to inspect a type or an alias.

It takes a single element as an argument. The reason the template parameters is types as a variable arg sequence is becure if D does not allow (pre version 2.087) to say "I want either a type or alias over here, I don't care, I'll figure it out". But it does allow it when you use a template sequence parameter

methodDescription
$(DDOX_NAMED_REF bolts.iz.iz.of, `of`)True if the resolved type is the same as another resolved type
$(DDOX_NAMED_REF bolts.iz.iz.sameAs, `sameAs`)True if T and U are the same "thing" (type, alias, literal value)
$(DDOX_NAMED_REF bolts.iz.iz.nullType, `nullType`)True if the resolved type is typeof(null)
$(DDOX_NAMED_REF bolts.iz.iz.unaryOver, `unaryOver`)True if the resolved type a unary funtion over some other types
$(DDOX_NAMED_REF bolts.iz.iz.binaryOver, `binaryOver`)True if the resolved type a binary funtion over some other types
$(DDOX_NAMED_REF bolts.iz.iz.functionOver, `functionOver`)True if the resolved type an n-ary funtion over n types
$(DDOX_NAMED_REF bolts.iz.iz.refType, `refType`)True if the resolved type a reference type
$(DDOX_NAMED_REF bolts.iz.iz.valueType, `valueType`)True if the resolved type a value type
$(DDOX_NAMED_REF bolts.iz.iz.literalOf, `literalOf`)True if the resolved type is a literal of a type of T
$(DDOX_NAMED_REF bolts.iz.iz.literal, `literal`)True if the resolved type is a literal
$(DDOX_NAMED_REF bolts.iz.iz.copyConstructable, `copyConstructable`)True if resolved type is copy constructable
$(DDOX_NAMED_REF bolts.iz.iz.nonTriviallyCopyConstructable, `nonTriviallyCopyConstructable`)True if resolved type is non-trivially copy constructable
$(DDOX_NAMED_REF bolts.iz.iz.triviallyCopyConstructable, `triviallyCopyConstructable`)True if resolved is trivially copy constructable
$(DDOX_NAMED_REF bolts.iz.iz.equatableTo, `equatableTo`)True if resolved type is equatabel to other
$(DDOX_NAMED_REF bolts.iz.iz.nullTestable, `nullTestable`)True if resolved type can be checked against null
$(DDOX_NAMED_REF bolts.iz.iz.nullSettable, `nullSettable`)True if resolved type can be set to null
$(DDOX_NAMED_REF bolts.iz.iz.refDecl, `refDecl`)True if resolved type is declred with ref or is a function that returns ref

Members

Aliases

ResolvedType
alias ResolvedType = TypesOf!Aliases[0]
Undocumented in source.

Enums

binaryOver
eponymoustemplate binaryOver(U...)

See: bolts.traits.functions.isBinaryOver

functionOver
eponymoustemplate functionOver(U...)

See: bolts.traits.functions.isFunctionOver

literalOf
eponymoustemplate literalOf(T)

See: bolts.traits.symbols.isLiteralOf

unaryOver
eponymoustemplate unaryOver(U...)

See: bolts.traits.functions.isUnaryOver

Manifest constants

copyConstructable
enum copyConstructable;

See: bolts.traits.types.isCopyConstructable

literal
enum literal;

See: bolts.traits.symbols.isLiteral

nonTriviallyCopyConstructable
enum nonTriviallyCopyConstructable;

See: bolts.traits.types.isNonTriviallyCopyConstructable

nullSettable
enum nullSettable;

See: bolts.traits.types.isNullSettable

nullTestable
enum nullTestable;

See: bolts.traits.types.isNullTestable

nullType
enum nullType;

See: bolts.traits.types.isNullType

nullable
deprecated enum nullable;
Undocumented in source.
refDecl
enum refDecl;

See: bolts.traits.symbols.isRefDecl

refType
enum refType;

See: bolts.traits.types.isRefType

triviallyCopyConstructable
enum triviallyCopyConstructable;

See: bolts.traits.types.isTriviallyCopyConstructable

valueType
enum valueType;

See: bolts.traits.types.isValueType

Templates

equatableTo
template equatableTo(Other...)

See: bolts.traits.types.areEquatable

of
template of(Other...)

See: bolts.traits.symbols.isOf

sameAs
template sameAs(Other...)

See: bolts.traits.symbols.isSame

Examples

1 int i = 3;
2 int j = 4;
3 int *pi = null;
4 
5 // Is it resolved to the same type as another?
6 static assert( iz!i.of!int);
7 static assert(!iz!i.of!(int*));
8 static assert( iz!3.of!i);
9 static assert(!iz!int.of!pi);
10 
11 // Is it the same as another?
12 static assert( iz!i.sameAs!i);
13 static assert(!iz!i.sameAs!j);
14 static assert( iz!1.sameAs!1);
15 static assert(!iz!1.sameAs!2);
16 
17 // Using std.meta algorithm with iz
18 import std.meta: allSatisfy, AliasSeq;
19 static assert(allSatisfy!(iz!int.of, 3, 4, int, i));
20 
21 /// Is it a function over
22 static assert( iz!(a => a).unaryOver!int);
23 static assert( iz!((a, b) => a).binaryOver!(int, int));
24 static assert( iz!((a, b, c, d) => a).functionOver!(int, int, int, int));
25 
26 // Is this thing a value or reference type?
27 struct SValueType {}
28 class CRefType {}
29 static assert( iz!SValueType.valueType);
30 static assert(!iz!CRefType.valueType);
31 static assert(!iz!SValueType.refType);
32 static assert( iz!CRefType.refType);
33 
34 static assert( iz!"hello".literalOf!string);
35 static assert(!iz!3.literalOf!string);
36 
37 // Is this thing copy constructable?
38 static struct SDisabledCopyConstructor { @disable this(ref typeof(this)); }
39 static assert(!iz!SDisabledCopyConstructor.copyConstructable);
40 static assert( iz!int.copyConstructable);
41 
42 // Does this thing define a custom copy constructor (i.e. non-trivial copy constructor)
43 static struct SCopyConstructor { this(ref typeof(this)) {} }
44 static assert( iz!SCopyConstructor.nonTriviallyCopyConstructable);
45 static assert(!iz!SCopyConstructor.triviallyCopyConstructable);
46 static assert(!iz!int.nonTriviallyCopyConstructable);
47 static assert( iz!int.triviallyCopyConstructable);
48 
49 // Can we equate these things?
50 static assert( iz!int.equatableTo!3);
51 static assert(!iz!3.equatableTo!string);
52 
53 // What null-semantics does the type have
54 
55 // Is it settable to null?
56 static struct SNullSettable { void opAssign(int*) {} }
57 static assert( iz!pi.nullSettable);
58 static assert( iz!SNullSettable.nullSettable);
59 static assert(!iz!i.nullSettable);
60 
61 // Is it checable with null? (i.e. if (this is null) )
62 static assert( iz!pi.nullTestable);
63 static assert(!iz!SNullSettable.nullTestable);
64 static assert(!iz!i.nullTestable);
65 
66 // Is it typeof(null)?
67 static assert(!iz!int.nullType);
68 static assert( iz!null.nullType);
69 static assert( iz!(typeof(null)).nullType);

See Also

Meta