76template <
typename TYPE, std::
size_t SIZE >
77std::size_t
numof(
const TYPE (&)[SIZE]) {
111constexpr auto wrap_at(
const T& c, std::size_t i) ->
const typename T::value_type&
113 return c[i % c.size()];
149constexpr auto clamp_to_edge(
const T& c, std::size_t i) ->
const typename T::value_type& {
179template <
typename T, std::
size_t N>
180constexpr const T& random_at(
const T (&array)[N]) {
182 std::size_t index = random_value % N;
210constexpr const typename T::value_type& random_at(
const T& container,
const typename T::value_type& default_value =
typename T::value_type{}) {
211 if (container.empty()) {
212 return default_value;
215 std::size_t index = random_value % container.size();
216 return container[index];
219#define memsetz(addr_,bytesize_) memset(addr_,0x00,bytesize_)
235extern std::string
fs(
const char* format, ...);
248extern void*
mallocz(
size_t bytesize_ );
Header file for the Mersenne Twister random number generator.
uint32_t genrand_int32(void)
Generates a random number on [0, 0xffffffff] interval.
Definition mt.c:110
void * mallocz(size_t bytesize_)
Allocate and zero-initialize a block of memory.
Definition sublibc.cpp:25
constexpr auto clamp_to_edge(const T &c, std::size_t i) -> const typename T::value_type &
Returns a clamped reference to an element at index i in container c.
Definition sublibc.h:149
std::size_t numof(const TYPE(&)[SIZE])
Retrieve the size of an array.
Definition sublibc.h:77
constexpr auto wrap_at(const T &c, std::size_t i) -> const typename T::value_type &
Returns a wrapped reference to an element at index i in container c.
Definition sublibc.h:111
void print_mallinfo()
Print memory allocation information.
Definition sublibc.cpp:10
std::string fs(const char *format,...)
Format a string with variable arguments.
Definition sublibc.cpp:32