I have a function that currently accepts 2 vectors that can contain any plain old data …
template <class T>
void addData(const vector<T>& yData, vector<T> xData)
{ .. }
Question:
- Would it be possible to modify it to take two
std::arrayor twostd::vector, or even a combination thereof, given that these containers take a different number of template arguments?
Why not just use this, which works with any container using random-access iterators, including plain old arrays. If you can use iteration instead of indexing, you can do away with the random-access requirement as well.
C++03 version (doesn’t support plain old arrays):