There are two types of arguments in D. The runtime one (which you are well aware of) and the compile time one. A compile time argument is a constant passed in during construction of a symbol.

But here is the thing, it isn't just limited to functions, you can have it on classes as well.

---
class Foo(bool b) {
        bool get() { return b; }
}

void main() {
        Foo!true v = new Foo!true;
        assert(v.get);
}
---

Same logic going on.

---
bool get(bool b)() {
        return b;
}

void main() {
        assert(get!true == true);
}
---

It can do more than a simple boolean being passed in, but that is the gist. Templates are wonderful (also read the spec!).

Reply via email to