Allows dynamic cast from one RCPtr instantiation to another. Based on
same function for std::shared_ptr.
Change-Id: Idc8723ea90dfd2843a3c5b602f5e42fad7a36613
Reviewed-on: http://review.couchbase.org/76552
Tested-by: Build Bot <build@couchbase.com>
Reviewed-by: James Harrison <james.harrison@couchbase.com>
Reviewed-by: Daniel Owen <owend@couchbase.com>
};
/**
+ * Dynamic cast for RCPtr. Modelled on method of the same name for
+ * std::shared_ptr.
+ */
+template <class T, class U>
+RCPtr<T> dynamic_pointer_cast(const RCPtr<U>& r) {
+ T* p = dynamic_cast<T*>(r.get());
+ return p ? RCPtr<T>(p) : RCPtr<T>();
+}
+
+/**
* Single-threaded reference counted pointer.
* "Single-threaded" means that the reference counted pointer should be accessed
* by only one thread at any time or accesses to the reference counted pointer