How efficient is `typeof(expr)`?

127 views Asked by At

How efficient is typeof when dealing with complex expressions?

Specifically, in the two cases:

  • complex expressions that consist entirely of constant parts needing no CTFE to evaluate

  • complex expressions that need to mixin() a CTFE'ed string.

I don't know if it's fundamentally different but those are the two cases that concern me.

1

There are 1 answers

3
Kozzi11 On BEST ANSWER

It depends, if you are interest in run time efficiency or compile time efficiency. typeof(expr) has zero run time overhead it is completly evaluated at compile time.

Compile time complexity is a quite low, so you generaly does not need to worried about it.