Bonjour,
J'aimerais faire une fonction QuickExponentiation() (je sais pas si je dois la nommer ainsi) template. J'ai essayé ce code:
Mais g++ me sort : déclaration de fonction invalide.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 template<typename T,T e> inline std:pair<T, T> QuickExponentiation(T p, const std::pair<T, T> point) { return p % 2 == 0 ? AddPoints(p, QuickExponentiation<e/2>(point), QuickExponentiation<e/2>(point)): AddPoints(p, QuickExponentiation<(e-1)/2>(point), AddPoints(p, QuickExponentiation<(e-1)/2>(point), point)); } template<typename T> inline std::pair<T, T> QuickExponentiation<1>(T p, const std::pair<T, T> point) { return point; }
Comment y remédier?
Edit: Le std:pair<T, T> entrainait cette erreur. De toute manière, il y avait d'autres problèmes donc j'ai dé-templatisé.
Merci.
Partager