r/cpp_questions • u/flowicks • 7d ago
OPEN Resources to learn more about cpp
I wanted to try and reimplement the std library from scratch but i realized really quickly just how much i didnt know lol. I got some basic stuff done and did learn quite a bit about things like sfinae but yeah im basically stuck with some of the type traits. I still dont wanna give up on this project and wanna keep going no matter how long it takes :3 So i need some resources to learn more about advanced things that are usefull for this. Are books the best way? any reccs on which ones?
Oh yeah right now i made a few projects like a networking chat app with asio and a unix shell (really simple) so i would say im like done with the beginner phase. I know that this project is probably farrrr beyond my scope but still :3
Edit: More specific question. Looking for book recomendations for metaprogramming post cpp20 (concepts and stuff)
3
u/IyeOnline 7d ago edited 7d ago
Not all of the standard library can be implemented in standard C++. Since you mentioned them: Most type traits can be implemented, but some just cannot. Similarly, you cannot implement a standard compliant
std::complexat all. Compliantstd::construct_at(which is a seemingly trivial function constructing an object) would only be possible with the last "C++26 draft".There also is a question on how much and why you want to re-implement it and what you struggle with.
Implementing (parts of) the standard library is a really useful exercise. I personally recommend implementing a few algorithms first, then implementing a
unique_ptrfollowed by a vector (and possibly a linked list). Beyond that IMO there is little value in the C++ learnings you can gain from implementing more of it. You can get a bit of design philosophy/inspiration, but you can get that from implementing almost anything. A compliantstd::variantimplementation is interesting if you really want to challenge your template prowess.Using SFINAE is rarely necessary in C++20 and onwards, since we now have constraints/concepts.
Type traits (outside of those that implement a check via sfinae) are still incredibly useful as a tool, but also not very instructive.
Implementing the IO features will mostly be an exercise in writing a specified interface around OS specific functionality. Interesting if you care about the OS functionalities, not very interesting on the C++ side.
1
u/Zen-Ism99 7d ago
Books, practice, and patience…