Requires C++23 (e.g., -std=c++23 for GCC/Clang, /std:c++latest for MSVC).


API Reference · Usage Guide · Releases
Features
- Name Generation. Randomly generates first names from popular name databases, organized by gender and culture.
- Surname Generation. Randomly generates surnames, organized by culture.
- Full Name Chaining. Append one or more names and surnames with an intuitive chainable API.
- 23 Cultures Supported. American, Argentinian, Australian, Brazilian, British, Bulgarian, Canadian, Chinese, Danish, Finnish, French, German, Kazakh, Mexican, Norwegian, Polish, Portuguese, Russian, Spanish, Swedish, Turkish, Ukrainian.
- ISO 2-Letter Codes.
to_culture() and to_gender() for converting strings to enums.
- Deterministic Seeding. Per-call
get_name(gender, culture, seed) for reproducible results, generator-level seed() / unseed() for deterministic sequences, and name::seed() for replaying a previous generation.
- Resource Inspection.
has_resources() lets you verify databases loaded before generating.
- Multi-Instance Support. Construct independent
ng instances with their own name databases and random engine.
Integration
namegen.hpp is the single required file released here. You need to add
Name generator that produces culture-aware names and surnames.
Name generator library — culture-aware name generation for C++23.
to the files you want to generate names and set the necessary switches to enable C++23 (e.g., -std=c++23 for GCC and Clang).
Additionally you must supply the name generator with the resources folder also available in the release.
Usage
Due to the necessity of supporting multiple culture characters and the way std::string works on Windows, this library uses std::wstring for all generated names.
When requesting a name for the first time the library will attempt to load the resource files (the default path is ./resources). Manually load the resources folder if it's in a different location.
ng::instance().
load(
"path/to/resources");
std::wstring name = ng::instance().get_name();
std::wstring female_name = ng::instance().get_name(dasmig::gender::f);
std::wstring bulgarian = ng::instance().get_name(dasmig::gender::m,
dasmig::culture::bulgarian);
std::wstring full = ng::instance().get_name().append_surname().append_surname();
auto n = ng::instance().get_name().append_surname();
for (const auto& part : n.parts())
std::wcout << part << L" ";
auto seeded = ng::instance().get_name(dasmig::gender::m,
dasmig::culture::american, 42);
auto replay = ng::instance().get_name(dasmig::gender::m,
dasmig::culture::american,
seeded.seed());
ng::instance().seed(100);
ng::instance().unseed();
ng my_gen;
my_gen.load("path/to/resources");
std::wstring name2 = my_gen.get_name().append_surname();
void load(const std::filesystem::path &resource_path)
Load name files from a directory.
For the complete feature guide — cultures, chaining, thread safety, seeding, and more — see the Usage Guide.
Disclaimer
Ukrainian and Russian surnames are all in their male or neutral versions.