ClassName *var = new ClassName [NumItems];
delete [] var;
memmove(&var[index], &var[index + 1], sizeof(ClassName) * (NumItems - (Index + 1));
Class* arrayOfClass = new arrayOfClass[N]; // fill array code skipped // delete element n of the array, leaving element N-1 in a destructible state std::move(arrayOfClass + n, arrayOfClass + (n + 1), arrayOfClass + N); // the only things that you may do with element N-1 are: // assign a new value to it // destruct it (e.g. when the entire array is destructed)
size_t bytes_to_move = NumItems - index + 1; memmove(var + index, var + index + NumItems, bytes_to_move* sizeof(ClassName));
Quote:Currently when a single item is removed I call memmove to shift everything over,..
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)