-
-
Save fabiogaluppo/f91f41c2bcb7023e64c8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <random> | |
#include <functional> | |
inline const std::string generate_ascii_random_string(std::string::size_type n) | |
{ | |
static std::default_random_engine generator; | |
static std::uniform_int_distribution<short> distribution(0x20, 0x7A); //ascii range from space to z | |
static auto rnd = std::bind(distribution, generator); | |
std::string s; | |
s.resize(n); | |
for (auto& ch : s) | |
ch = static_cast<char>(rnd()); | |
return s; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment