struct Deleter
Defined at line 132 of file ../../sdk/lib/c/dlfcn/dl/test/../tlsdesc-runtime-dynamic.h
The std::unique_ptr to own a TLS block needs a custom deleter to use the
`operator delete[]` *function* directly, rather than the `delete[]`
*operator*. This is to match the precise means of allocation, which has
to use the `operator new[]` function directly (not `new std::byte[n]`) so
as to use the overload that indicates (dynamic) alignment as well as size.
Since std::byte is both trivially-destructible and usable uninitialized,
there is no semantic difference between using the proper `new[]` and
`delete[]` operators (which in the general case ensure constructors and
destructors and formal C++ object lifetime rules) and using the underlying
allocator functions those operators call, which are called `operator
new[]` and `operator delete[]` to keep it confusing since they're neither
operators nor functions that take the same arguments as those operators.
But there is an important low-level difference, since the `new[]` and
`delete[]` operators implicitly use a hidden element count that's stored
as a size_t before the pointer (to allow `delete[]` to run the right
number of destructors); the underlying allocation includes space for this
hidden pointer, not just for the elements. So it always matters to
manually pair the precise allocator and deallocator functions being used.
Furthermore, which `operator delete[]` function signature is used to
deallocate a particular array should match which `operator new[]` function
signature was used to allocare it. The compiler would generate the
`operator new[]` taking the dynamic alignment argument for `new T[n]` when
the static alignof(T) is > __STDCPP_DEFAULT_NEW_ALIGNMENT__; in that case,
its `delete[]` on T* would use the `operator delete[]` function that takes
the alignment (and it could choose or not to use the one that also takes
the size). So this Deleter needs to recover the size and alignment of the
original allocation to call the correct `operator delete[]` signature.
The private BlockSizes helper class handles all this.
Public Methods
void operator() (std::byte * ptr)
Defined at line 133 of file ../../sdk/lib/c/dlfcn/dl/test/../tlsdesc-runtime-dynamic.h