3 ms·
I've never been a good at Templates. After reading this it seems that a lot of Template uses can be replaced with the generic lambdas using auto as the types go
by jason_slack 12y ago
I've never been a good at Templates. After reading this it seems that a lot of Template uses can be replaced with the generic lambdas using auto as the types going in.
Am I wrong or misunderstanding? I'm not saying completely but I feel like when I have used Templates I can now use this.
- dllthomas 12y agoMy understanding is that auto can serve some of the role of templates, but that has no particular tie to lambdas that I can see.
- Iftheshoefits 12y agoTemplates are the C++ implementation of "generics". Their utility extends far beyond lambdas-as-callables. The entire STL library is built using the Template feature of C++. Templates are far more important than the ability to do "true" object-oriented programming using other features, in my opinion. For a more concrete example that doesn't rely on the "authority" of an externally developed template library, consider that templates are also useful for static/compile-time polymorphism (see: Curiously Recurring Template Pattern).