Код: Выделить всё
template
class SlotArray {
static_assert(!std::is_array_v);
static_assert(!std::is_void_v);
using StorageType = std::aligned_storage_t;
public:
template
T* alloc(Args... args) {
std::size_t index = claimIndex();
return ::new(&slots[index]) T(std::forward(args)...);
}
void free(T* value) {
static_assert(sizeof(std::ptrdiff_t)
Подробнее здесь: [url]https://stackoverflow.com/questions/79493057/placement-new-reinterpret-cast-pointer-arithmetic-ub[/url]