In C++11 (which you're presumably using, otherwise there wouldn't be an unordered_map
), containers can be populated by a list initialiser:
static std::unordered_map<int,int> my_map {
{1, 1},
{2, 3},
//etc
};
Historically, the cleanest way would be to call a function that returns a populated container:
static std::unordered_map<int,int> my_map = make_map();