Topic: fstream & C-strings
Author: Chris.Theis@nospam.cern.ch ("Chris Theis")
Date: Sun, 27 Nov 2005 17:59:55 GMT Raw View
Hello,
as stated by the standard the fstream derivatives expect a const char*
parameter indicating the file name associated with the stream to be opened.
I wondered why there is no constructor accepting a const string& parameter,
which forces the user to convert any filename to an old C-style string
before passing it to the constructor. Is this simply a historical reason or
is there some deeper problem, which I might fail to see. Probably somebody
could shed some light on this issue.
Thanks
Chris
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]
Author: gwesp@no.spam.invalid (Gerhard Wesp)
Date: Tue, 29 Nov 2005 06:16:49 GMT Raw View
"Chris Theis" <Chris.Theis@nospam.cern.ch> wrote:
> before passing it to the constructor. Is this simply a historical reason or
> is there some deeper problem, which I might fail to see. Probably somebody
Failing to see a "deeper problem", I believe it is for historical reasons.
-Gerhard
--
Gerhard Wesp
Zuerich, Switzerland
+41 (0)76 505 1149 (mobile)
+41 (0)44 668 1878 (office)
+41 (0)44 200 1818 (office fax)
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]
Author: Michiel.Salters@tomtom.com
Date: Tue, 29 Nov 2005 00:16:39 CST Raw View
"Chris Theis" wrote:
> Hello,
>
> as stated by the standard the fstream derivatives expect a const char*
> parameter indicating the file name associated with the stream to be opened.
> I wondered why there is no constructor accepting a const string& parameter,
> which forces the user to convert any filename to an old C-style string
> before passing it to the constructor. Is this simply a historical reason or
> is there some deeper problem, which I might fail to see. Probably somebody
> could shed some light on this issue.
Historical (<iostream> and the STL came from different sources and were
incompletely merged), should be fixed in the next standard.
HTH,
Michiel Salters
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]
Author: dsp@bdal.de (=?ISO-8859-1?Q?Daniel_Kr=FCgler?=)
Date: Tue, 29 Nov 2005 07:34:21 GMT Raw View
Michiel.Salters@tomtom.com wrote:
> "Chris Theis" wrote:
>
> Historical (<iostream> and the STL came from different sources and were
> incompletely merged), should be fixed in the next standard.
Do you mean by introducing c'tors for std::string or (even better, I
think), the support of tr2::path? For everyone interested, I speak of
the promising proposal:
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1889.html#header-fstream
Greetings from Bremen,
Daniel
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]
Author: Dietmar Kuehl <dietmar_kuehl@yahoo.com>
Date: Wed, 30 Nov 2005 09:06:33 CST Raw View
Michiel.Salters@tomtom.com wrote:
> Historical (<iostream> and the STL came from different sources and were
> incompletely merged), should be fixed in the next standard.
What has 'std::string' to do with either the IOStream library or STL?
It came from neither of these sources...
--
<mailto:dietmar_kuehl@yahoo.com> <http://www.dietmar-kuehl.de/>
<http://www.eai-systems.com> - Efficient Artificial Intelligence
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]
Author: Harald.Nowak@infrasoft.co.at (Harald Nowak)
Date: Wed, 7 Dec 2005 03:36:31 GMT Raw View
Dietmar Kuehl schrieb:
> What has 'std::string' to do with either the IOStream library or STL?
> It came from neither of these sources...
This is of course correct - notwithstanding the C++ standards commitee
tried to blend the different parts of the C++ runtime ("old" runtime
components like string, iostreams library and STL for example) as
seamlessly together as possible - just consider the iterator like member
functions that have been added to string for that purpose (like begin(),
end() and such). Therefore I also have to conclude that the non existent
ctor for an iostream that takes a string for a filename is an oversight
by the commitee.
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]