#pragma once namespace nall { template<> struct vector : vector_base { using type = vector; using vector_base::vector_base; template auto appendl(U value, uint size) -> void { for(uint byte : range(size)) append(uint8_t(value >> byte * 8)); } template auto appendm(U value, uint size) -> void { for(uint byte : nall::reverse(range(size))) append(uint8_t(value >> byte * 8)); } //note: string_view is not declared here yet ... auto appends(array_view memory) -> void { for(uint8_t byte : memory) append(byte); } template auto readl(int offset, uint size) -> U { if(offset < 0) offset = this->size() - abs(offset); U value = 0; for(uint byte : range(size)) value |= (U)operator[](offset + byte) << byte * 8; return value; } auto view(uint offset, uint length) -> array_view { #ifdef DEBUG struct out_of_bounds {}; if(offset + length >= size()) throw out_of_bounds{}; #endif return {data() + offset, length}; } }; }