diff options
Diffstat (limited to 'src/common')
-rw-r--r-- | src/common/util/CountedPtr.h | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/src/common/util/CountedPtr.h b/src/common/util/CountedPtr.h index f2079c7c..5c2a48f0 100644 --- a/src/common/util/CountedPtr.h +++ b/src/common/util/CountedPtr.h @@ -52,6 +52,14 @@ public: _counter = new Counter(p); } + /** Make a NULL CountedPtr. + * It would be best if this didn't exist, but it makes these storable + * in STL containers :/ + */ + CountedPtr() + : _counter(NULL) + {} + ~CountedPtr() { release(); @@ -61,9 +69,10 @@ public: CountedPtr(const CountedPtr& copy) : _counter(NULL) { - assert(copy); assert(this != ©); - retain(copy._counter); + + if (copy) + retain(copy._counter); } /** Copy a CountedPtr to a valid base class. @@ -76,7 +85,11 @@ public: // Fail if this is not a valid cast if (y) { - T* const unused_variable = static_cast<Y* const>(y._counter->ptr); +#ifdef WITH_RTTI + T* const unused_variable = dynamic_cast<T* const>(y._counter->ptr); +#else + T* const unused_variable = static_cast<T* const>(y._counter->ptr); +#endif assert(unused_variable == y._counter->ptr); // shuts up gcc } |