Compile-Time Function Parameters That Aren't Types?

Adam D. Ruppe destructionator at gmail.com
Wed Feb 24 03:57:37 UTC 2021


On Wednesday, 24 February 2021 at 03:52:57 UTC, Kyle Ingraham 
wrote:
> The part that got my attention was `bool isBGR`. I was under 
> the impression that compile-time or template parameters were 
> only for types.

No, you can pass almost anything to them.

https://dlang.org/spec/template.html#template_value_parameter

and other surrounding sections

> Why would one write a function this way?

To specialize on information known at compile time. It will also 
call functions as-needed to get that value all at compile time.


More information about the Digitalmars-d-learn mailing list