0
我嘗試使用boost :: simple_segregated_storage,但我不能理解如何正確使用它。沒有任何樣品。我在下一個方法使用它:如何使用boost :: simple_segregated_storage?
boost::simple_segregated_storage<int> pStorage;
const int num_partitions = 100;
const int partition_sz = sizeof(int);
const int block_sz = partition_sz * num_partitions;
int block[block_sz] = {};
pStorage.segregate(block, block_sz, partition_sz);
int* pInt = (int*)pStorage.malloc(); // <-- Crashes here
但我收到崩潰。我做錯了什麼,錯在哪裏? 如何正確使用它?