Compile-time variables
Kayomn
spam at kayomn.net
Fri Apr 6 00:48:06 UTC 2018
I'll give a better example of what it is I'm trying to do.
These are node types. Their contents are not important in this
explanation, only that they operate as a tree structure.
class Node;
class RootNode : Node;
class SpriteNode : Node;
The result of getNodeID on a specific type is always the same. A
value representing it that is applied during compilation. The
value does not matter to the programmer, only that it is unique
and gets applied.
----------------------------------------------------------------------
uint nodeId1 = getNodeID!(Node)(); // 0.
uint nodeId2 = getNodeID!(SpriteNode)(); // 1.
uint comparison = getNodeID!(Node)(); // 0.
// True.
if (getNodeID!(Node)() == getNodeID!(Node)()) {
}
// False.
if (getNodeID!(SpriteNode)() == getNodeID!(Node)()) {
}
----------------------------------------------------------------------
More information about the Digitalmars-d-learn
mailing list