20 #ifndef _MEMORY_OPERATIONS_HPP_
21 #define _MEMORY_OPERATIONS_HPP_
31 static inline void ensure_minimum_memory(
size_t bytes_available,
size_t min_needed) {
32 if (bytes_available < min_needed) {
33 throw std::out_of_range(
"Insufficient buffer size detected: bytes available "
34 + std::to_string(bytes_available) +
", minimum needed " + std::to_string(min_needed));
38 static inline void check_memory_size(
size_t requested_index,
size_t capacity) {
39 if (requested_index > capacity) {
40 throw std::out_of_range(
"Attempt to access memory beyond limits: requested index "
41 + std::to_string(requested_index) +
", capacity " + std::to_string(capacity));
46 static inline size_t copy_from_mem(
const void* src,
void* dst,
size_t size) {
47 memcpy(dst, src, size);
52 static inline size_t copy_to_mem(
const void* src,
void* dst,
size_t size) {
53 memcpy(dst, src, size);
58 static inline size_t copy_from_mem(
const void* src, T& item) {
59 memcpy(&item, src,
sizeof(T));
64 static inline size_t copy_to_mem(T item,
void* dst) {
65 memcpy(dst, &item,
sizeof(T));
DataSketches namespace.
Definition: binomial_bounds.hpp:38