#!/usr/bin/env dub
/+ dub.sdl:
name "property_tree_type_only_instantiation"
targetPath "build"
dflags "-preview=in" "-preview=dip1000"
buildType "checked" {
buildOptions "optimize" "inline" "debugInfo"
}
+/
/// [`type-only-instantiation.d`](./type-only-instantiation.d) — is the CTFE limit about RECURSION, or about PATH-PARAMETERISED
/// INSTANTIATION? Same walk, type-only template parameters, evaluated at CTFE.
module (module) property_tree_type_only_instantiationtype-only-instantiation.d — is the CTFE limit about RECURSION, or about PATH-PARAMETERISED
INSTANTIATION? Same walk, type-only template parameters, evaluated at CTFE.
property_tree_type_only_instantiation;
import (package) stdstd.(module) std.traitsTemplates which extract information about types and symbols at compile time.
Category Templates Symbol Name traits fullyQualifiedName mangledName moduleName packageName Function traits isFunction arity functionAttributes hasFunctionAttributes functionLinkage FunctionTypeOf isSafe isUnsafe isFinal ParameterDefaults ParameterIdentifierTuple ParameterStorageClassTuple Parameters ReturnType SetFunctionAttributes variadicFunctionStyle Aggregate Type traits BaseClassesTuple BaseTypeTuple classInstanceAlignment EnumMembers FieldNameTuple Fields hasAliasing hasElaborateAssign hasElaborateCopyConstructor hasElaborateDestructor hasElaborateMove hasIndirections hasMember hasStaticMember hasNested hasUnsharedAliasing InterfacesTuple isInnerClass isNested MemberFunctionsTuple RepresentationTypeTuple TemplateArgsOf TemplateOf TransitiveBaseTypeTuple Type Conversion CommonType AllImplicitConversionTargets ImplicitConversionTargets CopyTypeQualifiers CopyConstness isAssignable isCovariantWith isImplicitlyConvertible isQualifierConvertible Type Constructors InoutOf ConstOf SharedOf SharedInoutOf SharedConstOf SharedConstInoutOf ImmutableOf QualifierOf Categories of types allSameType ifTestable isType isAggregateType isArray isAssociativeArray isAutodecodableString isBasicType isBoolean isBuiltinType isCopyable isDynamicArray isEqualityComparable isFloatingPoint isIntegral isNarrowString isConvertibleToString isNumeric isOrderingComparable isPointer isScalarType isSigned isSIMDVector isSomeChar isSomeString isStaticArray isUnsigned Type behaviours isAbstractClass isAbstractFunction isCallable isDelegate isExpressions isFinalClass isFinalFunction isFunctionPointer isInstanceOf isIterable isMutable isSomeFunction isTypeTuple General Types ForeachType KeyType Largest mostNegative OriginalType PointerTarget Signed Unconst Unshared Unqual Unsigned ValueType Promoted Misc lvalueOf rvalueOf Select select User-Defined Attributes hasUDA getUDAs getSymbolsByUDA
Source
std/traits.d
traits : (alias template) property_tree_type_only_instantiation.FieldNameTuple = std.traits.FieldNameTuple(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.
FieldNameTuple, (alias template) property_tree_type_only_instantiation.Fields = std.traits.Fields(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.
Fields, (alias template) property_tree_type_only_instantiation.isAggregateType = std.traits.isAggregateType(T)Detect whether type T is an aggregate type.
isAggregateType, (alias template) property_tree_type_only_instantiation.isPointer = std.traits.isPointer(T)Detect whether type T is a pointer.
isPointer,
(alias template) property_tree_type_only_instantiation.isSomeString = std.traits.isSomeString(T)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.
isSomeString, (alias template) property_tree_type_only_instantiation.PointerTarget = std.traits.PointerTarget(T : T*)Returns the target type of a pointer.
PointerTarget;
struct (struct) property_tree_type_only_instantiation.RowRow { (alias) object.string = stringstring (field) string property_tree_type_only_instantiation.Row.pathpath; (alias) object.string = stringstring (field) string property_tree_type_only_instantiation.Row.typetype; int (field) int property_tree_type_only_instantiation.Row.depthdepth; bool (field) bool property_tree_type_only_instantiation.Row.cutcut; }
/// Type-only template parameter; depth/prefix are RUNTIME (hence CTFE) values.
(struct) property_tree_type_only_instantiation.RowRow[] property_tree_type_only_instantiation.Row[] property_tree_type_only_instantiation.plan!(property_tree_type_only_instantiation.Node)(string prefix, int depth, int maxDepth) pure nothrow @safeType-only template parameter; depth/prefix are RUNTIME (hence CTFE) values.
plan(T)((alias) object.string = stringstring (parameter) string prefixprefix, int (parameter) int depthdepth, int (parameter) int maxDepthmaxDepth) pure nothrow
{
(struct) property_tree_type_only_instantiation.RowRow[] (local variable) property_tree_type_only_instantiation.Row[] rowsrows;
static foreach (i, name; (constant) string property_tree_type_only_instantiation.Node.fun!(label).NameOf = "label"FieldNameTuple!T)
{{
alias (alias) property_tree_type_only_instantiation.plan!(property_tree_type_only_instantiation.Node).F = stringF = (alias) std.traits.Fields!(property_tree_type_only_instantiation.Node) = (string, property_tree_type_only_instantiation.Vec2, property_tree_type_only_instantiation.Material, property_tree_type_only_instantiation.Node*)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.
Examples
import std.meta : AliasSeq;
struct S { int x; float y; }
static assert(is(Fields!S == AliasSeq!(int, float)));
Fields!(alias) T = property_tree_type_only_instantiation.NodeT[(constant) ulong property_tree_type_only_instantiation.plan!(property_tree_type_only_instantiation.Node).i = 0LUi];
static if ((template instance) std.traits.isPointer!stringisPointer!(alias) property_tree_type_only_instantiation.plan!(property_tree_type_only_instantiation.Node).F = stringF && (template instance) isAggregateType!(PointerTarget!F)isAggregateType!((alias) T = property_tree_type_only_instantiation.NodePointerTarget!(unresolved type) FF))
alias (alias) property_tree_type_only_instantiation.plan!(property_tree_type_only_instantiation.Node).Target = property_tree_type_only_instantiation.NodeTarget = (alias) T = property_tree_type_only_instantiation.NodePointerTarget!(alias) property_tree_type_only_instantiation.plan!(property_tree_type_only_instantiation.Node).F = property_tree_type_only_instantiation.Node*F;
else
alias (alias) property_tree_type_only_instantiation.plan!(property_tree_type_only_instantiation.Node).Target = stringTarget = (alias) property_tree_type_only_instantiation.plan!(property_tree_type_only_instantiation.Node).F = stringF;
enum (constant) bool property_tree_type_only_instantiation.plan!(property_tree_type_only_instantiation.Node).leaf = trueleaf = (template instance) std.traits.isSomeString!stringisSomeString!(alias) property_tree_type_only_instantiation.plan!(property_tree_type_only_instantiation.Node).Target = stringTarget || !(template instance) isAggregateType!TargetisAggregateType!(alias) property_tree_type_only_instantiation.plan!(property_tree_type_only_instantiation.Node).Target = property_tree_type_only_instantiation.Vec2Target;
const (local variable) const(string) pathpath = (parameter) string prefixprefix.(field) ulong string.lengthlength ? (parameter) string prefixprefix ~ "." ~ name : (constant) string property_tree_type_only_instantiation.plan!(property_tree_type_only_instantiation.Node).name = "label"name;
static if (leaf)
(local variable) property_tree_type_only_instantiation.Row[] rowsrows ~= (struct) property_tree_type_only_instantiation.RowRow((local variable) const(string) pathpath, (darray) stringF.(constant) string string.stringof = "string"stringof, (parameter) int depthdepth, false);
else
{
const (local variable) const(bool) cutcut = (parameter) int depthdepth + 1 >= (parameter) int maxDepthmaxDepth;
(local variable) property_tree_type_only_instantiation.Row[] rowsrows ~= (struct) property_tree_type_only_instantiation.RowRow((local variable) const(string) pathpath, (struct) property_tree_type_only_instantiation.Vec2F.(constant) string property_tree_type_only_instantiation.Vec2.stringof = "Vec2"stringof, (parameter) int depthdepth, (local variable) const(bool) cutcut);
if (!(local variable) const(bool) cutcut)
(local variable) property_tree_type_only_instantiation.Row[] rowsrows ~= property_tree_type_only_instantiation.Row[] property_tree_type_only_instantiation.plan!(property_tree_type_only_instantiation.Vec2)(string prefix, int depth, int maxDepth) pure nothrow @safeType-only template parameter; depth/prefix are RUNTIME (hence CTFE) values.
plan!(alias) property_tree_type_only_instantiation.plan!(property_tree_type_only_instantiation.Node).Target = property_tree_type_only_instantiation.Vec2Target((local variable) const(string) pathpath, (parameter) int depthdepth + 1, (parameter) int maxDepthmaxDepth);
}
}}
return (local variable) property_tree_type_only_instantiation.Row[] rowsrows;
}
struct (struct) property_tree_type_only_instantiation.Vec2Vec2 { float (field) float property_tree_type_only_instantiation.Vec2.xx = 0, (field) float property_tree_type_only_instantiation.Vec2.yy = 0; }
struct (struct) property_tree_type_only_instantiation.MaterialMaterial { (alias) object.string = stringstring (field) string property_tree_type_only_instantiation.Material.namename; (struct) property_tree_type_only_instantiation.Vec2Vec2 (field) property_tree_type_only_instantiation.Vec2 property_tree_type_only_instantiation.Material.offsetoffset; }
struct (struct) property_tree_type_only_instantiation.NodeNode { (alias) object.string = stringstring (field) string property_tree_type_only_instantiation.Node.labellabel; (struct) property_tree_type_only_instantiation.Vec2Vec2 (field) property_tree_type_only_instantiation.Vec2 property_tree_type_only_instantiation.Node.positionposition; (struct) property_tree_type_only_instantiation.MaterialMaterial (field) property_tree_type_only_instantiation.Material property_tree_type_only_instantiation.Node.materialmaterial; (struct) property_tree_type_only_instantiation.NodeNode* (field) property_tree_type_only_instantiation.Node* property_tree_type_only_instantiation.Node.parentparent; }
enum (constant) property_tree_type_only_instantiation.Row[] property_tree_type_only_instantiation.manifest = [Row("label", "string", 0, false), Row("position", "Vec2", 0, false), Row("position.x", "float", 1, false), Row("position.y", "float", 1, false), Row("material", "Material", 0, false), Row("material.name", "string", 1, false), Row("material.offset", "Vec2", 1, false), Row("material.offset.x", "float", 2, false), Row("material.offset.y", "float", 2, false), Row("parent", "Node*", 0, false), Row("parent.label", "string", 1, false), Row("parent.position", "Vec2", 1, false), Row("parent.position.x", "float", 2, false), Row("parent.position.y", "float", 2, false), Row("parent.material", "Material", 1, false), Row("parent.material.name", "string", 2, false), Row("parent.material.offset", "Vec2", 2, true), Row("parent.parent", "Node*", 1, false), Row("parent.parent.label", "string", 2, false), Row("parent.parent.position", "Vec2", 2, true), Row("parent.parent.material", "Material", 2, true), Row("parent.parent.parent", "Node*", 2, true)]manifest = property_tree_type_only_instantiation.Row[] property_tree_type_only_instantiation.plan!(property_tree_type_only_instantiation.Node)(string prefix, int depth, int maxDepth) pure nothrow @safeType-only template parameter; depth/prefix are RUNTIME (hence CTFE) values.
plan!(struct) property_tree_type_only_instantiation.NodeNode("", 0, 3); // ← evaluated at COMPILE TIME
void void D main()main()
{
import (package) stdstd.(module) std.stdioCategory Symbols File handles _popen File isFileHandle openNetwork stderr stdin stdout Reading chunks lines readf readfln readln Writing toFile write writef writefln writeln Misc KeepTerminator LockType StdioException
Standard I/O functions that extend core.stdc.stdio. core.stdc.stdio
is publically imported when importing std.stdio.
There are three layers of I/O:
The lowest layer is the operating system layer. The two main schemes are Windows and Posix.
C's stdio.h which unifies the two operating system schemes.
std.stdio, this module, unifies the various stdio.h implementations into
a high level package for D programs.
Source
std/stdio.d
stdio : (alias template) writefln = std.stdio.writefln(alias fmt, A...)(A args) if (isSomeString!(typeof(fmt)))Equivalent to $(D writef(fmt, args, '\n')).
writefln;
void std.stdio.writefln!(char, ulong, int)(in char[] fmt, ulong __param_1, int __param_2) @safeEquivalent to writef(fmt, args, '\n').
writefln("CTFE manifest for a CYCLIC type: %s rows, %s cuts",
(constant) property_tree_type_only_instantiation.Row[] property_tree_type_only_instantiation.manifest = [Row("label", "string", 0, false), Row("position", "Vec2", 0, false), Row("position.x", "float", 1, false), Row("position.y", "float", 1, false), Row("material", "Material", 0, false), Row("material.name", "string", 1, false), Row("material.offset", "Vec2", 1, false), Row("material.offset.x", "float", 2, false), Row("material.offset.y", "float", 2, false), Row("parent", "Node*", 0, false), Row("parent.label", "string", 1, false), Row("parent.position", "Vec2", 1, false), Row("parent.position.x", "float", 2, false), Row("parent.position.y", "float", 2, false), Row("parent.material", "Material", 1, false), Row("parent.material.name", "string", 2, false), Row("parent.material.offset", "Vec2", 2, true), Row("parent.parent", "Node*", 1, false), Row("parent.parent.label", "string", 2, false), Row("parent.parent.position", "Vec2", 2, true), Row("parent.parent.material", "Material", 2, true), Row("parent.parent.parent", "Node*", 2, true)]manifest.(field) ulong [Row("label", "string", 0, false), Row("position", "Vec2", 0, false), Row("position.x", "float", 1, false), Row("position.y", "float", 1, false), Row("material", "Material", 0, false), Row("material.name", "string", 1, false), Row("material.offset", "Vec2", 1, false), Row("material.offset.x", "float", 2, false), Row("material.offset.y", "float", 2, false), Row("parent", "Node*", 0, false), Row("parent.label", "string", 1, false), Row("parent.position", "Vec2", 1, false), Row("parent.position.x", "float", 2, false), Row("parent.position.y", "float", 2, false), Row("parent.material", "Material", 1, false), Row("parent.material.name", "string", 2, false), Row("parent.material.offset", "Vec2", 2, true), Row("parent.parent", "Node*", 1, false), Row("parent.parent.label", "string", 2, false), Row("parent.parent.position", "Vec2", 2, true), Row("parent.parent.material", "Material", 2, true), Row("parent.parent.parent", "Node*", 2, true)].lengthlength, () { int (local variable) int nn; foreach ((parameter) property_tree_type_only_instantiation.Row rr; (constant) property_tree_type_only_instantiation.Row[] property_tree_type_only_instantiation.manifest = [Row("label", "string", 0, false), Row("position", "Vec2", 0, false), Row("position.x", "float", 1, false), Row("position.y", "float", 1, false), Row("material", "Material", 0, false), Row("material.name", "string", 1, false), Row("material.offset", "Vec2", 1, false), Row("material.offset.x", "float", 2, false), Row("material.offset.y", "float", 2, false), Row("parent", "Node*", 0, false), Row("parent.label", "string", 1, false), Row("parent.position", "Vec2", 1, false), Row("parent.position.x", "float", 2, false), Row("parent.position.y", "float", 2, false), Row("parent.material", "Material", 1, false), Row("parent.material.name", "string", 2, false), Row("parent.material.offset", "Vec2", 2, true), Row("parent.parent", "Node*", 1, false), Row("parent.parent.label", "string", 2, false), Row("parent.parent.position", "Vec2", 2, true), Row("parent.parent.material", "Material", 2, true), Row("parent.parent.parent", "Node*", 2, true)]manifest) (local variable) int nn += (local variable) property_tree_type_only_instantiation.Row rr.(field) bool property_tree_type_only_instantiation.Row.cutcut; return (local variable) int nn; }());
foreach ((parameter) property_tree_type_only_instantiation.Row rr; (constant) property_tree_type_only_instantiation.Row[] property_tree_type_only_instantiation.manifest = [Row("label", "string", 0, false), Row("position", "Vec2", 0, false), Row("position.x", "float", 1, false), Row("position.y", "float", 1, false), Row("material", "Material", 0, false), Row("material.name", "string", 1, false), Row("material.offset", "Vec2", 1, false), Row("material.offset.x", "float", 2, false), Row("material.offset.y", "float", 2, false), Row("parent", "Node*", 0, false), Row("parent.label", "string", 1, false), Row("parent.position", "Vec2", 1, false), Row("parent.position.x", "float", 2, false), Row("parent.position.y", "float", 2, false), Row("parent.material", "Material", 1, false), Row("parent.material.name", "string", 2, false), Row("parent.material.offset", "Vec2", 2, true), Row("parent.parent", "Node*", 1, false), Row("parent.parent.label", "string", 2, false), Row("parent.parent.position", "Vec2", 2, true), Row("parent.parent.material", "Material", 2, true), Row("parent.parent.parent", "Node*", 2, true)]manifest)
void std.stdio.writefln!(char, int, string, string, string, string)(in char[] fmt, int __param_1, string __param_2, string __param_3, string __param_4, string __param_5) @safeEquivalent to writef(fmt, args, '\n').
writefln("%*s%s : %s%s", (local variable) property_tree_type_only_instantiation.Row rr.(field) int property_tree_type_only_instantiation.Row.depthdepth * 2, "", (local variable) property_tree_type_only_instantiation.Row rr.(field) string property_tree_type_only_instantiation.Row.pathpath, (local variable) property_tree_type_only_instantiation.Row rr.(field) string property_tree_type_only_instantiation.Row.typetype, (local variable) property_tree_type_only_instantiation.Row rr.(field) bool property_tree_type_only_instantiation.Row.cutcut ? " ⋯" : "");
}