Smart pointers was RE: [GD-General] Compile times
Brought to you by:
vexxed72
From: brian h. <bri...@py...> - 2002-12-16 02:16:40
|
> Hmm, I've seen smart pointers used on several projects and they have > never caused any problems. What sort of "ugly things" are you > referring to? Assuming that we're defining "smart pointer" as ref-counted, templatized pointer access, then here are the typical bugaboos: - non-deterministic destruction (a problem with general GC as well) - extremely slack model of ownership (a problem with general GC as well) - cascading destruction if you deref a root node - array support can be iffy depending on the implementation - cycles - bugs that arise if your implementation doesn't properly handle stack, static/global variables, or "special" memory that requires its own de- allocation (pointer to surfaces, pointer to AGP memory, etc.) All that said, there are some pretty solid implementations (Boost?) out there that I believe address at least the key issues. My gripes are generally more of the subjective stuff -- I think it obfuscates code, lends to programmer laziness because there's a poor concept of memory ownership and, deep down inside (okay, maybe right there at the surface), I just feel that retrofitting automatic memory management on a language that was clearly designed for manual memory management is a Bad Idea. -Hook |