Templates are definitely one of the main strengths of C++ that will make me stick with this language for many years to come. They're the closest thing to C++ introspection that we have right now and they allow you to basically make your own personal development environment with your own rules.
If you're interested in templates metaprogramming to do stuff at compile-time and not just using templates as a replacement for macros, these are a some must-watch talks:
- Walter E. Brown's talk in two parts: https://www.youtube.com/watch?v=Am2is2QCvxY and https://www.youtube.com/watch?v=a0FliKwcwXE
- Jody Hagins' talk (also in two parts): https://www.youtube.com/watch?v=tiAVWcjIF6o and https://www.youtube.com/watch?v=dLZcocFOb5Q
- Odin Holmes' talk which provides a close-to-scientific framework to reason about template optimizations (yes you can optimize them) and compilation times: https://www.youtube.com/watch?v=EtU4RDCCsiU , because
-ftime-trace
will not help you if you're working with very large expression templates resulting in a json dump weighing 30GB+ and you need to narrow down the problem by reasoning from first principles.