Boy, std.bitmanip.bigEndianToNative is annoying to use
H. S. Teoh via Digitalmars-d
digitalmars-d at puremagic.com
Fri May 22 12:39:12 PDT 2015
On Fri, May 22, 2015 at 07:21:40PM +0000, Jonathan M Davis via Digitalmars-d wrote:
[...]
> Isn't the problem that you're trying to convert to a ushort, and a
> ushort is _2_ bytes, not 4? If you sliced it correctly, it would
> compile. For instance, this code compiles just fine for me with dmd
> master:
>
> void main()
> {
> import std.bitmanip;
> auto buf = new ubyte[](32);
> auto result = bigEndianToNative!ushort(buf[0 .. 2]);
> }
>
> But if I change it to buf[0 .. 4], then it fails to compile. So, the
> fact that bigEndianToNative is taking a static array is actually
> catching a bug for you.
[...]
face.palm();
head.hang!inShame();
self.crawlBackTo(hole);
T
--
Perhaps the most widespread illusion is that if we were in power we would behave very differently from those who now hold it---when, in truth, in order to get power we would have to become very much like them. -- Unknown
More information about the Digitalmars-d
mailing list