allow/raw/linear: add typed offset query
This commit is contained in:
parent
b7a4b8d1c0
commit
7d315c8095
@ -82,6 +82,16 @@ namespace util::alloc::raw {
|
||||
|
||||
size_t offset (const void*) const;
|
||||
|
||||
template <typename ValueT>
|
||||
size_t
|
||||
offset (ValueT const *ptr) const
|
||||
{
|
||||
CHECK_MOD (reinterpret_cast<uintptr_t> (ptr), sizeof (ValueT));
|
||||
CHECK_MOD (reinterpret_cast<uintptr_t> (data ()), sizeof (ValueT));
|
||||
|
||||
return ptr - util::cast::alignment<ValueT const*> (data ());
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
size_t
|
||||
offset (util::view<T*> ptr) const
|
||||
|
Loading…
Reference in New Issue
Block a user