From 5721888167973377817
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,e1300df19f14dad5,start
X-Google-Attributes: gidf78e5,public
X-Google-ArrivalTime: 1994-06-15 08:41:07 PST
Newsgroups: comp.std.c++
Path: nntp.gmd.de!xlink.net!howland.reston.ans.net!europa.eng.gtefsd.com!MathWorks.Com!news.duke.edu!concert!hearst.acc.Virginia.EDU!saips.cv.nrao.edu!news.cv.nrao.edu!bglenden
From: bglenden@colobus.cv.nrao.edu (Brian Glendenning)
Subject: Is this a valid conversion operator?
Message-ID: <BGLENDEN.94Jun15111836@colobus.cv.nrao.edu>
Sender: news@news.cv.nrao.edu
Organization: National Radio Astronomy Observatory
Date: Wed, 15 Jun 1994 15:18:35 GMT
Lines: 37


      template<class t> class complex
      {
      public:
          t real, im;
          operator complex<float>() const;
      };
      
      template<class t> complex<t>::operator complex<float>() const
      {
          complex<float> cf;
          cf.real = float(real);
          cf.im = float(im);
          return cf;
      }
      
      main()
      {
          complex<int> ci;
          complex<float> cf;  // It works if this line is commented out
          return 0;
      }

CFront compiles this, another compiler doesn't, with the message:

"test1.cc", line 8: Error: Cannot define a conversion from complex<float> to complex<float>.

As far as I can tell, the ARM doesn't disallow this, but I might be
missing something. Who's right?

[I realize that templated member functions will solve the problem a
better way, but we don't have 'em yet].

Brian
--
       Brian Glendenning - National Radio Astronomy Observatory
bglenden@nrao.edu          Charlottesville Va.           (804) 296-0286


