diff options
Diffstat (limited to 'gdbsupport')
-rw-r--r-- | gdbsupport/gdb_obstack.h | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/gdbsupport/gdb_obstack.h b/gdbsupport/gdb_obstack.h index 20f8886..7b3bb05 100644 --- a/gdbsupport/gdb_obstack.h +++ b/gdbsupport/gdb_obstack.h @@ -133,14 +133,18 @@ struct auto_obstack : obstack { obstack_free (this, obstack_base (this)); } }; -/* Objects are allocated on obstack instead of heap. */ +/* Objects are allocated on obstack instead of heap. This is a mixin + that uses CRTP to ensure that the type in question is trivially + destructible. */ +template<typename T> struct allocate_on_obstack { allocate_on_obstack () = default; void* operator new (size_t size, struct obstack *obstack) { + static_assert (IsFreeable<T>::value); return obstack_alloc (obstack, size); } |