3 ms·
You probably meant the stdc++, not the STL. But I agree, in C++11 one can use smart pointers which help avoiding many memory management pitfalls and make memory
by shmerl 13y ago
You probably meant the stdc++, not the STL. But I agree, in C++11 one can use smart pointers which help avoiding many memory management pitfalls and make memory ownership mode more explicitly defined through the language itself.
- wfunction 13y agoPeople nowadays never mean SGI (or anything other than the C++ standard library) when they say "STL", so it's a good time to stop correcting them.
- shmerl 13y agoStill, it's not exactly correct. Unless you read STL as STandard Library.
- eropple 13y agoIn this case I did mean the STL-derived bits specifically. C++ collections, iterators and <algorithm> are awesome. When you're used to C for writing native code and your options are arrays, linked lists, or oh-god-I-hope-I-wrote-this-hashtable-correctly, this stuff is amazing. I guess they're not called the STL anymore, but I tend to use the term to refer to them specifically. I actually only very rarely use smart pointers in my main C++ project; my game has a simple lifecycle and wouldn't benefit from them much, though I could probably stand to use unique_ptr more than I do. The primary place I use them is to use std::auto_ptr to clean up after myself when dealing with try-catch blocks--I standardized on them before really understanding unique_ptr and my use of them is single-function-limited so I kept it consistent. The game itself is modeled on a stack-based state machine and I'm able to pretty easily reason about my object lifetimes within each state without smart pointers.