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]
Other format: [Raw text]

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


> | Without this methods being const (which they should be IMHO from a
> | logical perspective, as they do not change the internal state of the
> | stream but simply return state information), methods that use these
> | methods can not be const.
> | This "can not be const" will easily cascade into upper layers, which
> | reduces quality and safeness of the code.
> | 
> | What are your doubts? Is there anything I might miss?
> 
> What do you do with a const stream?

class Parser {
   std:ifstream m_in;
   public: bool isOK() const { return m_in.is_open(); }
};

?

Vladimir



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