Hello Daniel,

thanks for your answers. Please see my answers below.

On Fri, Aug 12, 2011 at 11:37 PM, Daniel James <dnljms@gmail.com> wrote:
On 11 August 2011 14:22, Ovanes Markarian <om_boost@keywallet.com> wrote:
>
> If the defined stream is only 2 bytes long why is 2 a valid stream position?

There needs to be an offset for the end of the stream. I'm actually
not sure if it should be -1 for larger values though.
To be honest, I do not understand what offset do you mean here. Why does array_device needs an offset for the end of stream and stringstream does not? I looked up the behavior in the standard (for stringstream, since I assume array_device should behave similar in regards of positioning and memory related nature of stringstream) and there is clearly written that seeking to an invalid pos will cause tellg to return -1. I would propose to change the array_device to be more consistent with stringstream in these regards. 
In Standard C++ IOStreams and Locales by A. Langer & K. Kreft is also stated for basic_istream<char_type, traits_type>& seekg(...) on p.489:
"Repositions this to the location designated by pos, by calling this->rdbuf()->pubseekpos(off) [or] (off,dir). !!! Failures are indicated by the state of *this.!!! [...]"
And now the tellg counterpart:
"If this->fail()==true, returns pos_type(-1), othewise [...]"
In case of stringstream seekg immediately fails if seeking the stream to an invalid pos, without any offsets. I find the behavior of array_device somehow unnatural, especially for the case where I would like to mimic other std streams for easier testing.


> Why is eof always false? Do you think this behavior is buggy?

IIRC in streams eof is only set when you try to read past the end of the file.
Yes, you are right. I double checked this in the Standard. As the my upper answer points out, the stream should be in the failed state.


Many thanks for your time,
Ovanes