Many people browsing through these forums are familiar with the sizeof-operator in C++. The use of it is simple:
sizeof(int); // Return the size of int.
And, if you want to get the size of an int array, you use the sizeof-operator like this:
sizeof(array) / sizeof(array[0]); // Return the size of int array.
As you know, this only works with int arrays. Fortunately, C++ contains templates, so why can get the size of an array of any type. Here's a typical implementation:
std::array of different size are different types. So you will be making a lot of functions (that will need to be templatized),
¿what consequences does this have?
You could use std::vector instead, if you can handle that overhead of dynamic allocation.
When working with arrays and functions you've got several options
_ Use a centinel that marks the end
_ Pass the size of the array
_ Pass a pointer to the end/pass the end
As has been noted above, in your UniqueRand example SizeOf(array) is equivalent to SizeOf(T*) because despite naming the parameter array, it is only a pointer.