I'm writing a virtual method, and one of its parameter a std::vector. Inside, I use std::unordered_set with the same value_type of the std::vector.
But, I may change the value_type of the std::vector, and I don't want to change each time the type inside the code. To better understand what I am saying (English is not my native language), see the code below please.
run(std::vector<Node> &data) {
std::unordered_set<Node> var;
}
And what I expect is a thing like this :
run(std::vector<Node> &data) {
std::unordered_set<data::value_type> var;
}
And, of course, it doesn't work. Thank you in advance.
EDIT : Thank you very much for the answers, and especially this one : https://stackoverflow.com/a/56563062/11203604
The answers with the function template, it is impossible : it is an overloaded function (virtual). As for the class template, for technical reason in my future work, I can not make it template as it could be a public class.
Thank you.