InputStream and OutputStream non const getPosition


#1

Hi Jules,

Is there a reason why getPosition in InputStream and OutputStream
is not a const function ?

Thanks,


#2

I always prefer to make things const, but there could be all sorts of stream subclasses that might need to use that in a non-const way. e.g. a subclass might want to cache the position when it’s called.

I admit, it could probably be const and not break anything, but it’s just to avoid being a problem in future.


#3

usually you will use mutable in that case.

my 2 cents.


#4

True. I’m not saying it’s right or wrong - that’s just how I wrote that class (a long time ago now!) If I changed it, every subclass would have to update their methods. Maybe I’ll make it const, I don’t know…


#5

No problem.
I understand easily.

Thanks,


#6