The integral type to convert the first T.sizeof bytes to.
The endianness that the bytes are assumed to be in.
The range to read from.
1 ubyte[] buffer = [1, 5, 22, 9, 44, 255, 8]; 2 assert(buffer.peek!uint() == 17110537); 3 assert(buffer.peek!ushort() == 261); 4 assert(buffer.peek!ubyte() == 1); 5 6 assert(buffer.peek!uint(2) == 369700095); 7 assert(buffer.peek!ushort(2) == 5641); 8 assert(buffer.peek!ubyte(2) == 22); 9 10 size_t index = 0; 11 assert(buffer.peek!ushort(&index) == 261); 12 assert(index == 2); 13 14 assert(buffer.peek!uint(&index) == 369700095); 15 assert(index == 6); 16 17 assert(buffer.peek!ubyte(&index) == 8); 18 assert(index == 7);
import std.algorithm.iteration : filter; ubyte[] buffer = [1, 5, 22, 9, 44, 255, 7]; auto range = filter!"true"(buffer); assert(range.peek!uint() == 17110537); assert(range.peek!ushort() == 261); assert(range.peek!ubyte() == 1);
Takes a range of ubytes and converts the first T.sizeof bytes to T. The value returned is converted from the given endianness to the native endianness. The range is not consumed.