From e4a4e0dc872bee27d6833ad299533531dc2b3fb3 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Thu, 4 Dec 2025 17:28:59 -0500 Subject: [PATCH] xo-alloc: + static_asserts in GC root helpers --- include/xo/alloc/GC.hpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/include/xo/alloc/GC.hpp b/include/xo/alloc/GC.hpp index be2ff071..214027b7 100644 --- a/include/xo/alloc/GC.hpp +++ b/include/xo/alloc/GC.hpp @@ -249,10 +249,18 @@ namespace xo { void remove_gc_root(IObject ** addr); /** convenience wrapper **/ + template - void add_gc_root_dwim(gp * p) { this->add_gc_root(reinterpret_cast(p->ptr_address())); } + void add_gc_root_dwim(gp * p) { + static_assert(std::is_convertible_v); + this->add_gc_root(reinterpret_cast(p->ptr_address())); + } + template - void remove_gc_root_dwim(gp * p) { this->remove_gc_root(reinterpret_cast(p->ptr_address())); } + void remove_gc_root_dwim(gp * p) { + static_assert(std::is_convertible_v); + this->remove_gc_root(reinterpret_cast(p->ptr_address())); + } /** may optionally use this to observe GC copy phase. * Will be invoked once _per surviving object_, so not cheap.