From: Alexei Sheplyakov Date: Mon, 23 Feb 2009 12:03:16 +0000 (+0200) Subject: Fix compilation failure due to (template) operator- defined in factor.cpp X-Git-Tag: release_1-6-0~82 X-Git-Url: https://www.ginac.de/ginac.git//ginac.git?p=ginac.git;a=commitdiff_plain;h=4cf514ec7a3d8dbb447eaa46747f31a9fc9cf159 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. --- 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();