diff --git a/xo-alloc/include/xo/alloc/GC.hpp b/xo-alloc/include/xo/alloc/GC.hpp index be2ff071..214027b7 100644 --- a/xo-alloc/include/xo/alloc/GC.hpp +++ b/xo-alloc/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.