title: istream::tellg() returns -1 when used with my custom streambuf class?
body: <p>I'm trying to create an <code>istream</code> that reads directly from a raw memory buffer.</p>
  
  <p>I found a nice way to do this in another post on here:</p>
  
  <pre><code>  class membuf : public basic_streambuf&lt;char&gt;
    {
    public:
        membuf(char* p, size_t n) {
            setg(p, p, p + n);
        }
    };
  </code></pre>
  
  <p>Then I create my <code>istream</code> using this <code>membuf</code>:</p>
  
  <pre><code>    membuf mb(dataPointer, dataLength);
      istream reader(&amp;mb);
  </code></pre>
  
  <p>I then read using <code>getline()</code> and <code>&gt;&gt;</code> operators, and everything is wonderful. However, I can't seem to use <code>seekg()</code> to rewind back to the beginning of my buffer, and <code>istream::tellg()</code> always returns <code>-1</code>.</p>
  
  <p>Do I need to write some more code to get these to work, or is this doomed to failure?</p>