setg
sets the pointers for the read area; it has no effect on
writing.
The simplest solution is to use two different streambuf
,
MemBufIn
and MemBufOut
: the first calls setg
, and the
second setp
. If you want a bidirectional stream, or to
support seeking, it gets more complicated.