public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: Boris von Loesch <vonloesch@gmail.com>
To: gcc-help@gcc.gnu.org
Subject: Re: Problem with implicit conversion (GCC 3.4.1)
Date: Thu, 26 Aug 2004 22:17:00 -0000	[thread overview]
Message-ID: <41a2e2dc04082612547497f4c8@mail.gmail.com> (raw)
In-Reply-To: <BAY1-F23F1yBgD2nfTX0001cafe@hotmail.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;
> }

  reply	other threads:[~2004-08-26 19:54 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-08-26 19:54 Suresh Lakshmanan
2004-08-26 22:17 ` Boris von Loesch [this message]
  -- strict thread matches above, loose matches on Subject: below --
2004-08-26 17:46 lrtaylor
2004-08-26 14:16 Boris von Loesch

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=41a2e2dc04082612547497f4c8@mail.gmail.com \
    --to=vonloesch@gmail.com \
    --cc=gcc-help@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).