I try to make a generic cross product function :
template<class ContainerType1, class ContainerType2, typename ReturnType>
std::vector<ReturnType> cross_product(const ContainerType1& a, const ContainerType2& b)
{
assert((a.size()==3)&&(b.size==3));
return {a[1]*b[2]-a[2]-b[1], a[2]*b[0]-a[0]*b[2], a[0]*b[1]-a[1]*b[0]};
}
the line
std::vector<double> A = cross_product(p_r2,p_r1);
give me the error :
error : couldn't deduce template parameter ‘ReturnType’
Is there a way to keep the genericity, and avoid to declare ReturnType as, for example, double ?
Aucun commentaire:
Enregistrer un commentaire