This is the mail archive of the
mailing list for the libstdc++ project.
Re: Should basic_*stream::is_open() be const?
On Fri, Aug 13, 2004 at 06:44:00PM +0200, Gabriel Dos Reis wrote:
> Joe Buck <Joe.Buck@synopsys.COM> writes:
> | Any decent design process by a designer unaware of the defect in the
> | standard (and that's what it is) would probably specify that the
> | Parser::isOK method is const, because it does not alter either the actual
> | or the logical state of any of the members. Good C++ design requires that
> | const be used as much as possible, because it greatly simplifies the
> | maintainance of the code (when undesired write operations occur, there are
> | fewer places to look.
> Const-correctness is a good design principle. However, it is not a dogma,
> which is why I'm aksing the question.
Designing standard APIs in such a way as to impede the use of
const-correctness, and then arguing to all who point out the fact one's
believe that a Parser object should have no const methods seems dogmatic.
In this case, const-correctness is impossible without casting away const,
using a mutable member, or other similar hacks, and arguing that this
doesn't matter because people shouldn't design that way is troubling.
The key is that if the API of standard libraries is designed to support
those who like strict const-correctness, the library also works just fine
for programmers who never use "const" at all in their own code, but not