Boost logo

Boost Users :

From: Andrew McDonald (andrew.mcdonald_at_[hidden])
Date: 2006-05-15 23:28:18


The stringstream (or ostringstream)

stringstream ss("Hello", ios_base::out);

will create a stringstream with the output sequence initialised to "Hello" and the position set to the _beginning_ of the sequence.
Thus any insertions will overwrite the value from the initialiser string.

There were various issues and debates after the 1998 standard came out [Issues 432 and Issue 45 (closed)]..and it is a little unclear to me what the resolution was...but I _think_ the following is correct...

- The standard does not mandate that ostringstream (more precisely the underlying stringbuf) supports ios_base::ate.
- However, many implementations do support it.

As an arbitrary test, compiling with Visual Express 2005 and using ios_base::ate, I find that this does move the position to the end of the sequence.

Note that stringstreams must support explicitly seeking to the end of the sequence;
e.g.

ostringstream oss("Hello");
oss.seekp(o, ios_base::end);
oss << " world";

regards,

Andrew McDonald
System Architect

Norwood Systems Australia Pty Ltd
Level 1, 71 Troy Terrace
PO Box 1281
Subiaco, WA 6904

Tel +61 8 9380 7766
Fax +61 8 9380 7733
andrew.mcdonald_at_[hidden]
  
The information in this email, and any attachments, may contain confidential information and is intended solely for the attention and use of the named addressee (s). It must not be disclosed to any person(s) without authorization. If you are not the intended recipient, or a person responsible for delivering it to the intended recipient, you are not authorized to, and must not, disclose, copy, distribute, or retain this message or any part of it. If you have received this communication in error, please notify the sender immediately.

 
 


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net