Should basic_*stream::is_open() be const?
Gabriel Dos Reis
gdr@integrable-solutions.net
Fri Aug 13 16:48:00 GMT 2004
Paolo Carlini <pcarlini@suse.de> writes:
| Gabriel Dos Reis wrote:
|
| >"Vladimir Merzliakov" <wanderer@rsu.ru> writes:
| >
| >| class Parser {
| >| std:ifstream m_in;
| >| public: bool isOK() const { return m_in.is_open(); }
| >| };
| > | | ?
| >
| >You're telling me that you need a const member function because you
| >need a constant member function. A parser, is kind of stream. My
| >question was what do you with a const stream.
| >
| Vladimir point is exactly that you don't need a const stream (pointless) to
| appreciate the usefulness of a const version of is_open().
I fear No.
| >If your const parser is not OK what do you to it?
| >
| Which const parser?
"const Parser" is a condensed way of say the context where the
function actually needs to be const.
| I see just a Parser class, above, that doesn't compile
| without my patch and does after, of course.
Yes, it does not compile, I know and I see it. Similarly, I can post
many function declarations along the same lines. The point of the
question, was in which actual context do you need that thing to be
const, i.e. is it actually called.
-- Gaby
More information about the Libstdc++
mailing list