I'm trying to figure this out, and, it's really annoying me. I have a function that converts either an array or a vector into a vector of complex numbers, but, I do not know how it would be possible for the function to be able to accept both double arrays, as well as double vectors. I've tried using templates, but, this does not seem to work.template
template<typename T>
vector<Complex::complex> convertToComplex(T &vals)
{
}
Value::Value(vector<double> &vals, int N) {
};
Value::Value(double *vals, int N) {
};
What I am hoping for is this:
int main()
{
double[] vals = {1, 2, 3, 4, 5};
int foo = 4;
Value v(vals, foo); // this would work and pass the array to the constructor, which would
// then pass the values to the function and covert this to a
// vector<complex>
}
I could do the same for a vector as well.. I don't know whether or not templates are the right approach for this.