Can I somehow make a map of template parameters? let's say I have the following function:
template<typename T>
T SumCoefficients(const std::vector<T>& coeffs) {
T sum = static_cast<T>(0);
for(int i=0; i<100; ++i) {
sum += SomeFunc<T>(i) * coeffs[i];
}
return sum;
}
// explicit instantiation
template double SumCoefficients(const std::vector<double>& coeffs);
template float SumCoefficients(const std::vector<float>& coeffs);
template Vector3d SumCoefficients(const std::vector<Vector3d >& coeffs);
now, let's say I don't want to call SomeFunc<T>(i) but instead, if T==float, I want to use SomeFunc<float>, if T==double I want to use SomeFunc<double>, but if T==Vector3d I don't want to use SomeFunc<Vector3d> but instead SomeFunc<double>
now of course I could explicitely implement template <> Vector3d SumCoefficients(std::vector<Vector3d > coeffs) { ... } and then make the explicit call to SomeFunc<double>, but I wonder if there is an elegant way that gives me the same result with only a single template implementation plus explicit instantiation.