Created
July 14, 2018 16:51
-
-
Save jingzhehu/d293ee67c418cc14fd07164d6bde2123 to your computer and use it in GitHub Desktop.
Generate random id
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> | |
decltype(auto) generate_id(){ | |
std::string id("ID"); // Holds the ID, starting with the characters "ID" followed | |
std::uniform_int_distribution<int> dist(0, 10000); // by a random integer in the range [0-10000]. | |
std::random_device rd; | |
std::mt19937 engine(rd()); | |
id += std::to_string(dist(engine)); | |
return id; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment