From 4cf514ec7a3d8dbb447eaa46747f31a9fc9cf159 Mon Sep 17 00:00:00 2001 From: Alexei Sheplyakov Date: Mon, 23 Feb 2009 14:03:16 +0200 Subject: [PATCH 1/1] Fix compilation failure due to (template) operator- defined in factor.cpp GiNaC 1.5.0 fails to compile with g++ 3.4. The fix is simple: declare (and define) operator- (and operator+) only for (univariate) polynomials. --- ginac/factor.cpp | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/ginac/factor.cpp b/ginac/factor.cpp index b8a1fb8e..2f9157b9 100644 --- a/ginac/factor.cpp +++ b/ginac/factor.cpp @@ -218,8 +218,32 @@ static void expt_pos(umodpoly& a, unsigned int q) } } +template struct enable_if +{ + typedef T type; +}; + +template struct enable_if { /* empty */ }; + +template struct uvar_poly_p +{ + static const bool value = false; +}; + +template<> struct uvar_poly_p +{ + static const bool value = true; +}; + +template<> struct uvar_poly_p +{ + static const bool value = true; +}; + template -static T operator+(const T& a, const T& b) +// Don't define this for anything but univariate polynomials. +static typename enable_if::value, T>::type +operator+(const T& a, const T& b) { int sa = a.size(); int sb = b.size(); @@ -250,7 +274,11 @@ static T operator+(const T& a, const T& b) } template -static T operator-(const T& a, const T& b) +// Don't define this for anything but univariate polynomials. Otherwise +// overload resolution might fail (this actually happens when compiling +// GiNaC with g++ 3.4). +static typename enable_if::value, T>::type +operator-(const T& a, const T& b) { int sa = a.size(); int sb = b.size(); -- 2.44.0