Any better solution?
Taking your question literally, no. There is no better solution.
This will create a default constructed, and therefore empty std::map<int,int>
.
std::map<int,int> m;
solved How to create an empty std::map object? [closed]