std.stream.EndianStream ...
torhu
fake at address.dude
Wed Feb 7 22:20:31 PST 2007
nescire wrote:
> EndianStream es = new EndianStream( new MemoryStream() );
> ubyte b;
> es.read( b );
>
> dmd gives the error:
>
> function std.stream.EndianStream.read called with argument types:
> (ubyte)
> matches both:
> std.stream.EndianStream.read(short)
> and:
> std.stream.EndianStream.read(dchar)
>
> Which seems to suggest the EndianStream class does not have a void read( out ubyte ) method, even though it should inherit it from FilterStream.
It's hard to find anything about this in the docs. But it seems
overloads are not inherited by default, which is the same behavior as in
C++. EndianStream redefine most of the read() overloads, but not the
byte and ubyte versions. The read() methods does the actual
byteswapping, which wouldn't work on single-byte reads. So this is done
on purpose.
You would do 'alias SuperClass.method method;' to pull in 'method()'
overloads from SuperClass.
> And the following code compiles:
>
> EndianStream es = new EndianStream( new MemoryStream() );
> ubyte b;
> (cast(InputStream) es).read( b );
>
>
> Could someone explain? Am I missing something obvious, or is it a compiler bug?
I'm guessing this makes it call Stream's version of read(ubyte), which
will give the wrong result.
More information about the Digitalmars-d-learn
mailing list