This refactoring PR picks up the idea of #19626 and replaces all occurences of sizeof(x)/sizeof(x[0])
(or sizeof(x)/sizeof(*x)
, respectively) with the now-available C++17 std::size
(as suggested by sipa), making the macro ARRAYLEN
obsolete.
As preparation for this, two other changes are done to eliminate sizeof(x)/sizeof(x[0])
usage:
- all places where arrays are iterated via an index are changed to use C++11 range-based for loops If the index’ only purpose is to access the array element (as suggested by MarcoFalke).
std::vector
initializations are done viastd::begin
andstd::end
rather than using pointer arithmetic to calculate the end (also suggested by MarcoFalke).