This can make compilation slow but it can also make template writing very hard because a bug might only appear when a template is instantiated with certain types.
> This can make compilation slow but it can also make template writing very hard because a bug might only appear when a template is instantiated with certain types.
yup. templates are 'compiled' in 2 phases as follows:
- without instantiation at definition time, the code itself is checked for correctness, completely ignoring the template parameters.
- at instantiation time, the code is checked again to ensure that all parts depending on template parameters are valid.
the 2-phase translation breaks canonical notions about compile+link, where declarations of function is sufficient to compile its use...
`cout <<` is ugly and hard to use for anything but the simplest printing. Type safe printf seems like the obvious use case of variadic templates.
https://en.cppreference.com/w/cpp/utility/format and the actual proposal https://www.zverovich.net/2019/07/23/std-format-cpp20.html