1 #ifndef UTIL_STREAM_TYPED_STREAM_H 2 #define UTIL_STREAM_TYPED_STREAM_H 3 // A typed wrapper to Stream for POD types. 4 5 #include "util/stream/stream.hh" 6 7 namespace util { namespace stream { 8 9 template <class T> class TypedStream : public Stream { 10 public: 11 // After using the default constructor, call Init (in the parent class) TypedStream()12 TypedStream() {} 13 TypedStream(const ChainPosition & position)14 explicit TypedStream(const ChainPosition &position) : Stream(position) {} 15 operator ->() const16 const T *operator->() const { return static_cast<const T*>(Get()); } operator ->()17 T *operator->() { return static_cast<T*>(Get()); } 18 operator *() const19 const T &operator*() const { return *static_cast<const T*>(Get()); } operator *()20 T &operator*() { return *static_cast<T*>(Get()); } 21 }; 22 23 }} // namespaces 24 25 #endif // UTIL_STREAM_TYPED_STREAM_H 26