From dcee24278ed28d21cd3addffeeb8e5f9f7248602 Mon Sep 17 00:00:00 2001 From: "Claudius \"keldu\" Holeksa" Date: Tue, 17 Feb 2026 18:29:22 +0100 Subject: End of day --- lib/core/c++/memory.hpp | 62 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 lib/core/c++/memory.hpp (limited to 'lib/core/c++/memory.hpp') diff --git a/lib/core/c++/memory.hpp b/lib/core/c++/memory.hpp new file mode 100644 index 0000000..b6a089e --- /dev/null +++ b/lib/core/c++/memory.hpp @@ -0,0 +1,62 @@ +#pragma once + +#include "common.hpp" +#include "chunk.hpp" + +namespace kel { +namespace lbm { + +namespace impl { + +template +struct memory_size_helper; + +template +struct memory_size_helper> { + static constexpr uint64_t bytes = N; +}; + +template +struct memory_size_helper> { + static constexpr uint64_t bytes = saw::ct_multiply::value * memory_size_helper::bytes; +}; + +template +struct memory_size_helper> { + static constexpr uint64_t bytes = memory_size_helper::InnerSchema>::bytes; +}; + +template +class memory_estimate_helper final { +private: + + template + static void apply_i(saw::data& bytes){ + + if constexpr ( i < sizeof...(T)){ + using T_I = typename saw::parameter_pack_type::type; + + bytes.set(bytes.get() + memory_size_helper::bytes); + + apply_i(bytes); + } + } + +public: + + static void apply(saw::data& bytes){ + apply_i<0u>(bytes); + } +}; +} + +template +saw::data memory_estimate(){ + saw::data bytes; + + impl::memory_estimate_helper::apply(bytes); + + return bytes; +} +} +} -- cgit v1.2.3