Hi Nakamura!
An std::map can be initialized with empty curly braces
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
#include <iostream> #include <map> #include <string> void fn(std::map<int,std::string> mp = { }) { std::cout << mp.size() << std::endl; } int main() { fn({{ 4, "Hello" }}); fn(); return 0; } |
Output
1 2 |
1 0 |