Buffer.canRead

Indicates whether an array of length size or the given type can be read without any exceptions thrown.

  1. bool canRead(size_t size)
    class Buffer
    pure nothrow @safe @nogc
    bool
    canRead
    (
    size_t size
    )
  2. bool canRead()

Examples

t {
		
		import xbuffer.varint;
		
		Buffer buffer = new Buffer(cast(ubyte[])[128, 200, 3]);
		assert(buffer.canRead(2));
		assert(buffer.canRead(3));
		assert(!buffer.canRead(4));
		assert(buffer.canRead!byte());
		assert(buffer.canRead!short());
		assert(!buffer.canRead!int());
	

Meta