I’m learning about a technique used to find the number of elements in an array (so that I can hopefully starting writing sorting algorithms without requiring the length of the array to be passed with the array as a parameter) but in the tutorial, this line appears as the template declaration:
template <typename T, size_t N>
I honestly didn’t know you could declare multiple typenames in one template declaration, but furthermore what does “size_t N” do? is this a variable declaration inside of a template declaration as well?
size_tis a type that resemblesunsigned int. Having it in the template parameter just means that you pass asize_t, not a type.Nprobably represents the size of an array, which is an unsigned value. For example:In the example, I could have said:
because both template arguments are deduced.