Suppose that I have: unsigned char my2darray[A][B];
Is it possible to use std::fill
to set all values of the 2d array to a non-0 value?
I know a vector can be used but this is performance critical code and I can't afford dynamic allocations. Unfortunately, no C++11 is allowed.
Currently used in the code is memset(my2darray, 0x12, sizeof(my2darray));
but I want to replace all memset
with std::fill
if possible, as the type of the array could become a class in future.
Answers which work for any type, not just chars, appreciated.