Produit scalaire en méta-prog, problème :p
Bonjour à tous !
J'ai actuellement un petit problème pour coder une classe en méta-programmation pour calculer le produit scalaire. Voici pour l'instant ce que j'ai fait :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
| template <int N, typename T>
class A_MultD
{
public:
template <typename R1, typename R2>
static inline T f (const R1 & a, const R2 & b)
{
return (a[N]*b[N] + A_MultD<N+1, T>::f (a, b));
}
};
// Spécialisation pour N=3
template <typename T>
class A_MultD <3, T>
{
public:
template <typename R1, typename R2>
static inline T f (const R1 & a, const R1 & b)
{
return T();
}
}; |
Toutefois j'obtient des erreurs à la compilation :
Citation:
instantiated from `static T A_MultD<N, T>::f(const R1&, const R2&) [with R1 = SVec3<double>, R2 = SVec3<double>, int N = 1, T = double]'
instantiated from `static T A_MultD<N, T>::f(const R1&, const R2&) [with R1 = SVec3<double>, R2 = SVec3<double>, int N = 0, T = double]'
instantiated from `T DotProductT(const Vec3<T, Expr>&, const Vec3<T, R2>&) [with T = double, R1 = SVec3<double>, R2 = SVec3<double>]'
error: no matching function for call to `A_MultD<3, double>::f(const SVec3<double>&, const SVec3<double>&)'
:: === Build finished: 4 errors, 0 warnings ===
Visiblement il arrive correctement à instancier les premiers mais bloque pour N=3, pour la spécialisation en fait, et je ne comprends pas, ma fonction est bien définie :/.
Merci :)