Created
April 18, 2017 09:36
-
-
Save deque-blog/1f83418db6c0e287e498074a46729ca2 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
inline auto cpp_identifier_gen(int max_size) | |
{ | |
using namespace tiny_rand; | |
static const std::string HEAD_CHARS = "_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; | |
static const auto head_char_gen = choice_gen(HEAD_CHARS); | |
static const auto rest_gen = string_gen(max_size - 1, choice_gen(HEAD_CHARS + "1234567890")); | |
return [=](std::mt19937& bit_gen) -> std::string | |
{ | |
return std::string {1, head_char_gen(bit_gen)} + rest_gen(bit_gen); | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment