minior "cleanup"

thread
Brett 2024-06-06 02:44:28 -04:00
parent b314a62c5a
commit 7731ec9ebc
2 changed files with 4 additions and 10 deletions

View File

@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.25) cmake_minimum_required(VERSION 3.25)
project(blt-gp VERSION 0.0.17) project(blt-gp VERSION 0.0.18)
option(ENABLE_ADDRSAN "Enable the address sanitizer" OFF) option(ENABLE_ADDRSAN "Enable the address sanitizer" OFF)
option(ENABLE_UBSAN "Enable the ub sanitizer" OFF) option(ENABLE_UBSAN "Enable the ub sanitizer" OFF)

View File

@ -112,24 +112,18 @@ namespace blt::gp
return offset; return offset;
} }
template<typename CurrentArgument, blt::u64 index>
inline CurrentArgument& getArgument(stack_allocator& allocator) const
{
return allocator.from<CurrentArgument>(getByteOffset<index>());
}
template<blt::u64... indices> template<blt::u64... indices>
inline Return sequence_to_indices(stack_allocator& allocator, std::integer_sequence<blt::u64, indices...>) const inline Return sequence_to_indices(stack_allocator& allocator, std::integer_sequence<blt::u64, indices...>) const
{ {
return func(getArgument<Args, indices>(allocator)...); // expands Args and indices, providing each argument with its index calculating the current argument byte offset
return func(allocator.from<Args>(getByteOffset<indices>())...);
} }
[[nodiscard]] inline Return operator()(stack_allocator& allocator) const [[nodiscard]] inline Return operator()(stack_allocator& allocator) const
{ {
auto seq = std::make_integer_sequence<blt::u64, sizeof...(Args)>(); auto seq = std::make_integer_sequence<blt::u64, sizeof...(Args)>();
Return ret = sequence_to_indices(allocator, seq); Return ret = sequence_to_indices(allocator, seq);
constexpr auto total_bytes = (stack_allocator::aligned_size<Args>() + ...); allocator.pop_bytes((stack_allocator::aligned_size<Args>() + ...));
allocator.pop_bytes(total_bytes);
return ret; return ret;
} }