I have a template function, which return a vector of data. Now I try to use it with std::complex, but I need a explicit template specialization version of it.
#include <vector>
#include <complex>
template<typename T>
std::vector<T> FillData(unsigned int n)
{
std::vector<T> v;
return v;
}
template<>
std::vector<std::complex<double>> FillData(unsigned int n)
{
std::vector<std::complex<double>> v;
return v;
}
int main(int argc, char* argv[])
{
auto v1 = FillData<float>(10);
auto v2 = FillData<int>(10);
auto v3 = FillData<std::complex<double>>(10);
auto v4 = FillData<std::complex<float>>(10); // call the one not expected
}
My question is, how can I specialize the template with different type of std::complex? Do I need one explicit specialization for each type?
Thanks in advance.