Ne.app NeANT
The Ne.app NeANT User module of the NeANT distribution.
27.stringbuf.xsputn.stdcxx-576.cpp
Go to the documentation of this file.
1
27#include <sstream> // for stringbuf
28#include <string> // for string
29#include <cassert> // for assert()
30
31struct PubBuf: std::stringbuf
32{
33 char* Pbase () const { return this->pbase (); }
34};
35
36int main ()
37{
38 // 512 is the default buffer size of the basic_stringbuf
39 std::string s (512, 'a');
40
41 std::stringbuf sbuf (s);
42 PubBuf& buf = (PubBuf&)sbuf;
43
44 std::streamsize res = buf.sputn (buf.Pbase (), 128);
45 s.append (s.begin (), s.begin () + 128);
46
47 const std::string& str = buf.str ();
48
49 assert (res == 128);
50 assert (str.size () == s.size ());
51 assert (str == s);
52
53 return 0;
54}
#define res
Definition 17.names.cpp:531
#define buf
Definition 17.names.cpp:452
#define s
#define assert(expr)
Definition _cassert.h:40
const char * str
Definition exec.cpp:170