File size: 732 Bytes
1ce325b |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
#ifndef UTIL_STREAM_TYPED_STREAM_H
#define UTIL_STREAM_TYPED_STREAM_H
// A typed wrapper to Stream for POD types.
#include "stream.hh"
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
#endif // UTIL_STREAM_TYPED_STREAM_H
|