Presume I have a C++ header
utils.h
And I want to have some constant map available in multiple TUs(map is not inside a class, normal global variable/constant).
const std::map<int, std::string> ToString{{1,"1"}, {2, "2"}};
Should I declare it inline or static? In other words:
static const std::map<int, std::string> ToString{{1,"1"}, {2, "2"}};
or
inline const std::map<int, std::string> ToString{{1,"1"}, {2, "2"}};
(AFAIK both will work to prevent ODR violation, static by making the linkage internal, and inline by making it ok to have multiple definitions, but I could be wrong, I often make mistakes wrt ODR).
Note: I want to avoid solutions using extern.