This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
RE: Problem with implicit conversion (GCC 3.4.1)
- From: lrtaylor at micron dot com
- To: <vonloesch at gmail dot com>, <gcc-help at gcc dot gnu dot org>
- Date: Thu, 26 Aug 2004 10:27:39 -0600
- Subject: RE: Problem with implicit conversion (GCC 3.4.1)
Well, you've declared a <= operator that can compare to BasisF objects,
but you're trying to compare a BasisF object with a double, which you
haven't created an operator for:
min(t,2.0) -> ((t) <= (2.0) ? (t) > (2.0))
So, in your min macro, you are trying to compare the object t with the
double 2.0. You don't have an operator for that.
Thanks,
Lyle
-----Original Message-----
From: gcc-help-owner@gcc.gnu.org [mailto:gcc-help-owner@gcc.gnu.org] On
Behalf Of Boris von Loesch
Sent: Thursday, August 26, 2004 3:55 AM
To: gcc-help@gcc.gnu.org
Subject: Problem with implicit conversion (GCC 3.4.1)
Hello,
I have written a program that compiles just fine with GCC 3.3. With
GCC 3.4.1 it results in this error:
g++ -O0 -g3 -Wall -c -oTestp.o ../Testp.c
../Testp.c: In function `int main()':
../Testp.c:26: error: no match for 'operator<=' in 't <= 2.0e+0'
Please help me, I have no idea where the problem is.
Here is the code:
template <class T> class BasisF;
template <class T> inline bool operator<=(const BasisF<T> &a, const
BasisF<T> &b){return a.x <= b.x;}
template<class T> class BasisF{
public:
T x;
BasisF(const T &_x = T()): x(_x){}
BasisF(const BasisF &_b): x(_b.x){}
~BasisF(){}
BasisF& operator= (const T &_x){
x(_x);
return *this;
}
friend bool operator<=<>(const BasisF &a, const BasisF &b);
};
#define min(a,b) ((a) <= (b) ? (a) : (b))
int main(){
BasisF<double> t(1);
if (min(t,2.0)<=0) return 1;
return 0;
}
Regards,
Boris