In C++, i want to build a string only container from a template.
For example:
template<typename T>
void show(const T & t) { // the T can be map<string, string> or <string, float> or <string, int>
std::unordered_map<std::string, std::string> r;
for (const auto & i : t) {
const auto & j = i.first;
const auto & k = i.second; // TODO: how to
// make k as string, possible type of k can be
// int float or string???
// put them into r
}
return r;
}
How can i implement this?
Aucun commentaire:
Enregistrer un commentaire