I made this function to convert a vector into a valarray:
template <typename T> valarray<T>* ValArrayTools::vectorToValArray(vector<T>* vector) {
valarray<T>* val = new valarray<T>(vector->size());
for(int i = 0; i < vector->size(); i++)
{
val[i] = vector[i];
}
return val;
}
I tried to use a template so that I can use this function with every possible type.
Now I want to convert a
vector<short int> buffer;
into a
valarray<short int>* data;
by using
sf->data = ValArrayTools::vectorToValArray<short int>(&buffer);
But I get this error:
CMakeFiles\LPC-Vocoder_Tests.dir/objects.a(ShortFileLoader.cpp.obj): In function `ZN15ShortFileLoader17generateShortFileEv':
C:/Users/****/Documents/Uni/SS18/**Projekt/LPC-Vocoder/src/ShortFileLoader.cpp:33: undefined reference to `std::valarray<short>* ValArrayTools::vectorToValArray<short>(std::vector<short, std::allocator<short> >*)'