Fix C++11 compatibility issue in topic.h

In C++11, shared_ptr has an explicit operator bool which means that a shared_ptr can't be implicitly converted to a bool. Therefore an explicit cast is needed.