home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!sun-barr!ames!agate!forney.berkeley.edu!jbuck
- From: jbuck@forney.berkeley.edu (Joe Buck)
- Newsgroups: comp.lang.c++
- Subject: Re: istrstream
- Date: 2 Sep 1992 01:13:43 GMT
- Organization: U. C. Berkeley
- Lines: 23
- Message-ID: <1814g7INNr59@agate.berkeley.edu>
- References: <1992Sep1.225259.1533@Warren.MENTORG.COM>
- NNTP-Posting-Host: forney.berkeley.edu
-
- In article <1992Sep1.225259.1533@Warren.MENTORG.COM> adk@Warren.MENTORG.COM (Ajay Kamdar) writes:
- >Why do istrstream constructors take a char* instead of a const char* ?
- >This either stops me from reading a formatted input string (which I get
- >as a const char*) as an istrstream, or compels me to cast away the const
- >on the string when constructing the istrstream.
-
- This annoys me too. The reason appears to be that istrstream and
- ostrstream are both derived from strstream, and it is the strstream
- constructor that requires the "char *" argument. Still, it would be nice
- if this could be avoided. I despise casting away const, and currently
- this is the only place where I feel compelled to do it. It still may
- not be safe, because of putback.
-
- Depending on the implementation, I suppose that it is possible that
- istream::putback(char) might modify the argument to the istrstream
- constructor, which could cause trouble if you passed a string argument
- and the code modified the string (possibly causing a bus error if the
- string is in ROM).
-
-
-
- --
- Joe Buck jbuck@ohm.berkeley.edu
-