Hacker News new | ask | show | jobs
by _0w8t 2703 days ago
C++ templates are not typed structually. The compiler does not assign types to them at all. Rather they are treated as macros and the type assignment and checking happens during the expansion. For example, one can write a template that has no valid expansion, but as long as nobody uses it, the compiler accepts it.

In sense templates are similar to dynamic languages. Except in C++ it is the compiler, not runtime, that evaluates the templates.