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.
The index to start reading from (instead of starting at the front). If index is a pointer, then it is updated to the index after the bytes read. The overloads with index are only available if hasSlicing!R is true.
ubyte[] buffer = [1, 5, 22, 9, 44, 255, 8]; assert(buffer.peek!uint() == 17110537); assert(buffer.peek!ushort() == 261); assert(buffer.peek!ubyte() == 1); assert(buffer.peek!uint(2) == 369700095); assert(buffer.peek!ushort(2) == 5641); assert(buffer.peek!ubyte(2) == 22); size_t index = 0; assert(buffer.peek!ushort(&index) == 261); assert(index == 2); assert(buffer.peek!uint(&index) == 369700095); assert(index == 6); assert(buffer.peek!ubyte(&index) == 8); 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.