Given:
template<typename T> class A {
B b;
std::vector<T> vec1;
std::vector<T> vec2;
}
I'd like B to have a member function that fill() that takes a reference to those to vectors and fills vec2 with values of T depending on some information contained in b.
One way of doing this is overloading fill() for each possible argument T:
fill(const std::vector<float>& a, std::vector<float>& b)
and so on but this will mean a lot of unnecessary duplication as the operations are the same for every possible T. Inside of fill() I could use vector::value_type for the calculations but I don't know how to declare it in such a way that it takes every kind of std::vector. The obvious way would be to use a free function with templates. Is there a simpler way of doing this?