diff --git a/CMakeLists.txt b/CMakeLists.txt index c972a4f..f056e7e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.25) -project(blt-gp VERSION 0.0.30) +project(blt-gp VERSION 0.0.31) option(ENABLE_ADDRSAN "Enable the address sanitizer" OFF) option(ENABLE_UBSAN "Enable the ub sanitizer" OFF) diff --git a/include/blt/gp/program.h b/include/blt/gp/program.h index 79d10db..8da47a3 100644 --- a/include/blt/gp/program.h +++ b/include/blt/gp/program.h @@ -83,7 +83,7 @@ namespace blt::gp if constexpr (sizeof...(Args) > 0) { - (add_non_context_argument(), ...); + (add_non_context_argument(operator_id), ...); } argc_t argc; diff --git a/include/blt/gp/stack.h b/include/blt/gp/stack.h index ce05dff..5d9f96d 100644 --- a/include/blt/gp/stack.h +++ b/include/blt/gp/stack.h @@ -41,6 +41,7 @@ namespace blt::gp template void push(T&& value) { + static_assert(std::is_trivially_copyable_v && "Type must be bitwise copyable!"); using NO_REF_T = std::remove_reference_t; auto ptr = allocate_bytes(); head->metadata.offset = static_cast(ptr) + aligned_size(); @@ -139,7 +140,26 @@ namespace blt::gp stack_allocator() = default; - stack_allocator(const stack_allocator& copy) = delete; + stack_allocator(const stack_allocator& copy) + { + head = nullptr; + block* list_itr = nullptr; + + // start at the beginning of the list + block* current = copy.head; + while (current != nullptr) + { + list_itr = current; + current = current->metadata.prev; + } + // copy all the blocks + while (list_itr != nullptr) + { + push_block(list_itr->metadata.size); + std::memcpy(head->buffer, list_itr->buffer, list_itr->storage_size()); + list_itr = list_itr->metadata.next; + } + } stack_allocator& operator=(const stack_allocator& copy) = delete;