This is the mail archive of the libstdc++@gcc.gnu.org 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]

Re: PATCH : basic_fstream::is_open()



> > http://anubis.dkuug.dk/jtc1/sc22/wg21/docs/lwg-closed.html#73
> > 
> > not a defect......

I'm not convinced.

A const stream may not be usable for anything but that doesn't mean that a stream should never be passed as const. 

For example if you know that a function will never modify a stream, the stream should be passed as a const reference. Such a function should be able to query the stream to find its current state since this does not modify the stream (finally a loophole to Heisenberg ;).

eg.

bool streamOpen( const fstream & strm )
{
	return strm.is_open();
}


The reference above is a bit terse. What would be the intention of forcing is_open() to be non-const when its semantics indicate that it is a query operation and should not modify the stream?

Is it fair to impose this restriction?

Is there some reason why asking if a stream is open should change it?

Should I be arguing to some other group about this? It's more a C++ standard question by the sound of things.

Rich



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