+/// Upcast in a class hierarchy with a virtual base class
+// We (clang) need the definition of SGVirtualWeakReferenced for the static_cast
+template<class T>
+typename boost::enable_if<
+ boost::is_base_of<SGVirtualWeakReferenced, T>,
+ T*
+>::type
+SGWeakReferenced::WeakData::up_cast(SGWeakReferenced* ptr)
+{
+ // First get the virtual base class, which then can be used to further
+ // upcast.
+ return dynamic_cast<T*>(static_cast<SGVirtualWeakReferenced*>(ptr));
+}
+