See: bolts.traits.functions.isBinaryOver
See: bolts.traits.functions.isFunctionOver
See: bolts.traits.symbols.isLiteralOf
See: bolts.traits.functions.isUnaryOver
See: bolts.traits.types.isCopyConstructable
See: bolts.traits.symbols.isLiteral
See: bolts.traits.types.isNonTriviallyCopyConstructable
See: bolts.traits.types.isNullSettable
See: bolts.traits.types.isNullTestable
See: bolts.traits.types.isNullType
See: bolts.traits.symbols.isRefDecl
See: bolts.traits.types.isRefType
See: bolts.traits.types.isTriviallyCopyConstructable
See: bolts.traits.types.isValueType
See: bolts.traits.types.areEquatable
See: bolts.traits.symbols.isOf
See: bolts.traits.symbols.isSame
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);
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