I want to create my own Tuple type
Ola Fosheim Grøstad
ola.fosheim.grostad at gmail.com
Mon Jan 11 10:24:34 UTC 2021
On Monday, 11 January 2021 at 09:42:39 UTC, Ola Fosheim Grøstad
wrote:
> I though maybe it would be nice in general to be able to create
> static indexed type by having a special field name pattern, but
> I will have a another look at staticMap (I don't really want
> the full staticMap into object.d though).
This is the core of staticMap, I find it problematic to do this
kind of string mixin in object.d:
private enum staticMapExpandFactor = 150;
private string generateCases()
{
string[staticMapExpandFactor] chunks;
chunks[0] = q{};
static foreach (enum i; 0 .. staticMapExpandFactor - 1)
chunks[i + 1] = chunks[i] ~ `F!(Args[` ~ i.stringof ~
`]),`;
string ret = `AliasSeq!(`;
foreach (chunk; chunks)
ret ~= `q{alias staticMap = AliasSeq!(` ~ chunk ~ `);},`;
return ret ~ `)`;
}
private alias staticMapBasicCases =
AliasSeq!(mixin(generateCases()));
More information about the Digitalmars-d-learn
mailing list