template <typename T, std::size_t size>
void printArray(const std::array<T, size>& myArray)
{
for (auto element : myArray)
std::cout << element << ' ';
std::cout << '\n';
}
Why is std::size_t being used? What are the benefits of size_t vs unsigned int?
std::size_tas its name clearly shows, is the standard type to store values for sizes of objects. It is the alaise of largest unsigned integer used by current standard(std::uint64_t) and can represent the largest possible virtual size. I don't find it practical to load a multi-GB file as a byte array in RAM; but if that's what must be done and the workstation can have a sufficiently large amount of RAM, then no other fundamental built-in type is capable of storing the size of resulting array or a proper index into it.