Hacker News new | ask | show | jobs
by tsimionescu 1703 days ago
Well, that's still instructive about how library code that aims to be efficient and portable has to look in C++. It's not representative of most application / business layer code, and it's definitely not good learning material.

But, if choosing C++, at some point you will have to write code like that as a project matures and must target different compiler versions and platforms.

1 comments

No, at no point should you use the standard library to understand how to write C++ code. The standard library has a specific clause in the C++ standard that exempts it from rules about undefined behavior. For example, that link I pasted to implement a std::vector is not something that is permissible to use by non-standard library code, it is full of undefined behavior that is permissible for use by the standard library but not permissible for use by ordinary code.

To the extent that one can learn how to write cross-platform efficient and generic C++ code, there is always a better example to learn from than the standard library.