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: Boris von Loesch <vonloesch at gmail dot com>
- To: gcc-help at gcc dot gnu dot org
- Date: Thu, 26 Aug 2004 21:54:01 +0200
- Subject: Re: Problem with implicit conversion (GCC 3.4.1)
- References: <BAY1-F23F1yBgD2nfTX0001cafe@hotmail.com>
- Reply-to: Boris von Loesch <vonloesch at gmail dot com>
Thanks for your replay.
This code works, but why does your code work and my not? Why does it
not compile with gcc 3.4.1 but with gcc 3.3?
Boris
On Thu, 26 Aug 2004 17:27:36 +0000, Suresh Lakshmanan
<suresh_lakshmana@hotmail.com> wrote:
> Try the code below. You could use std::min template in STL, so that you can
> force conversion
> to the template parameter.
>
> template<class T> class BasisF {
> T x;
> public:
>
> 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) {
> return a.x <= b.x;
> }
> };
>
> #define min(a,b) ((a) <= (b) ? (a) : (b))
>
> int main(){
> BasisF<double> t(1);
> if (min(t, 2.0)<= 0) {
> return 1;
> }
>
> return 0;
> }