The previous implementation used an std::stringstream to concatenate
the generated random string.
The new one uses a simple preallocated std::string, as the size of the
output is already known - it is the length parameter.
It also uses std::generate_n() instead of an explicit loop, making the
code more concise and potentially faster, as no calls to
std::string::operator+= are needed.
Calling GenerateRandomString(1'000'000) with the std::stringstream-based
implementation allocated 16 times, for a total of 3'173'516 bytes.
The new one cuts this down to 4 allocs, for a total of 1'076'864 bytes.