3 ms·
What are you talking about? auto_ptr? shared_ptr? You don't pay for these if you don't use them; the language gives you the option of trading safety for spe
by timr 18y ago
What are you talking about? auto_ptr? shared_ptr? You don't pay for these if you don't use them; the language gives you the option of trading safety for speed. That's what I meant when I said that you don't have to pay for the features.
In any case, the reference-counting used by the safe pointers is probably an order of magnitude less heavy than a garbage collector. Even if you use them, you aren't paying that much...
- tptacek 18y agoYou don't think it's nitpicky to suggest that C++ gives you automatic memory "for free", as long as you don't ever use it? Garbage collection is not an "order of magnitude" more heavy than reference counting, and there's more than one axis to measure memory management on --- in fact, there are several axes for allocation transactions alone. Just as importantly, if you go to Google Code Search and randomly select ten C++ projects that (a) have more than 10,000 lines of ".cpp" and ".i" file code and (b) use shared_ptr, I'm betting you're going to find that 8 of them rewrote some of the memory allocator for performance reasons. All the fancy template BS in the world doesn't save you from the fact that "new" is just "malloc", and there's no one allocator design that works for every program.