3 ms·
I like to make a very important distinction with templates in C++, categorizing uses into three classes: 1) "Java" generics. That is, anything you could do wit
by hazzen 16y ago
I like to make a very important distinction with templates in C++, categorizing uses into three classes:
1) "Java" generics. That is, anything you could do with generics in Java. No one should have an issue using templates like this.
2) Non-recursive "typedef" programming. That is, uses like "::value_type" in the STL containers. These are incredibly useful to have around when writing generic algorithms, but their overuse leads to unparseable code to some set of C++ programmers. Use with caution, but still use.
3) Recursive templates and other subtle uses I haven't covered with the above two. Try very, very, very hard to avoid.
That makes the "will my coworkers understand this code?" question very easy to answer.
- dons 16y ago4) Implementing Turing-complete type level languages :-)
- keveman 16y agoWhere would you place expression templates that help designers to embed simple domain specific languages in C++? The end user doesn't have to know much about templates, but this approach leads to high performance AND very concise and expressive code.