▲ | TillE 5 days ago | ||||||||||||||||
> VisualC++ doesn’t have its source code available Got all the way here and had to look back up to see this post was from 2019. The MSVC standard library has been open source for several years now. https://github.com/microsoft/STL Though to be perfectly honest, setting a breakpoint and looking at the disassembly is probably easier than reading standard library code. | |||||||||||||||||
▲ | snfernandez 5 days ago | parent | next [-] | ||||||||||||||||
I was working at MS at the time and actually had access to the source code (my project involved devdiv). I don't remember the exact details, but I opted for not adding any of my "private" knowledge to the post. I agree with you that I prefer looking at optimized assembly with symbols rather than following code through files (which are usually filled with #ifdefs and macros). | |||||||||||||||||
▲ | tialaramex 5 days ago | parent | prev [-] | ||||||||||||||||
As STL (nominative determinism at work) points out in the r/cpp thread about this, even when that git repo didn't exist you could have gone to see how this template works because C++ has to monomorphize generics somehow and that means when you write shared_ptr<goose> your C++ compiler needs to compile the source code for shared_ptr with the T replaced by goose. But you're correct, while I can read https://doc.rust-lang.org/src/alloc/sync.rs.html (where Rust's Arc is defined) ... ... good luck to me in https://github.com/microsoft/STL/blob/main/stl/inc/memory There are tricks to cope with C++ macros not being hygienic, layered on top of tricks to cope with the fact C++ doesn't have ZSTs, tricks to reduce redundancy in writing all this out for related types, and hacks to improve compiler diagnostics when you do something especially stupid. Do its maintainers learn to read like this? I guess so, as it's Open Source. | |||||||||||||||||
|