// A typed wrapper to Stream for POD types. | |
namespace util { namespace stream { | |
template <class T> class TypedStream : public Stream { | |
public: | |
// After using the default constructor, call Init (in the parent class) | |
TypedStream() {} | |
explicit TypedStream(const ChainPosition &position) : Stream(position) {} | |
const T *operator->() const { return static_cast<const T*>(Get()); } | |
T *operator->() { return static_cast<T*>(Get()); } | |
const T &operator*() const { return *static_cast<const T*>(Get()); } | |
T &operator*() { return *static_cast<T*>(Get()); } | |
}; | |
}} // namespaces | |