dctfe

How efficient is `typeof(expr)`?


How efficient is typeof when dealing with complex expressions?

Specifically, in the two cases:

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


Solution

  • 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.