Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> You can't blame C++ generics on compatibility with C, because C doesn't have them. The culprit isn't manual memory management either.

This is arguable. C doesn't have generics but if you look at the std::string example posted above as a "bad example", it indeed has some C backwards compatibility hacks.

In particular, std::allocator<...> is repeated many times. That is an attempt at making the string type (and other containers) at least partially compatible with manual memory management.

std::string is an overengineered and complicated solution compared to string types in other languages (and C heritage plays a part in it), it is not a good example of generics.

Posting that litany of C++ template code (which is essentially std::map<std::string, std::string> fully expanded, not what you'd actually write) is not a very good example of generics use.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: