This is the mail archive of the mailing list for the libstdc++ project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Should basic_*stream::is_open() be const?

Paolo Carlini <> writes:

| Gabriel Dos Reis wrote:
| >"Vladimir Merzliakov" <> 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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]