Article View: comp.std.c++
Article #2266Re: Q: is A a = 100; equivalent to A a (100); ?
From: Alex Martelli
Date: Fri, 20 Oct 1995 16:38
Date: Fri, 20 Oct 1995 16:38
44 lines
2345 bytes
2345 bytes
b91926@fsgm01.fnal.gov (David Sachs) writes:
...
>easy to produce a case in which X x(a); and X x=a; behave differently,
>where a is a class object, of a class that has a conversion operator to
>X&, and another higher priority conversion to something accepted by a
>constructor of class X. then:
>X x(a) uses higher priority conversion by overloading rules
>X x=a uses X(a.operator X&)
I think I'm confused here -- what would be a "higher priority conversion"
from a class object a to something accepted by a constructor of class X,
than an operatorX&() member of a's class (call that class A)...?
It seems to me that the highest priority conversion of them all would
be "no conversion at all", i.e. assume class X has a constructor that
accepts an A, as in...:
class X:
class A{ public: operatorX&() const; };
class X{ public: X(const A&); X(const X&); }
Even in this case, wouldn't the two usages...:
A a;
X x1(a);
X x2=a;
just both be _ambiguous_...? I do suspect I may be somewhat
confused here, so would appreciate clarification (ideally with
draft standard chapter&verse reference, thanks!).
Alex
--
DISCLAIMER: these are TOTALLY personal opinions and viewpoints, NOT connected
in any way with my employer, nor any other organization or individual!
Email: martelli@cadlab.it Phone: +39 (51) 597313
CAD.LAB s.p.a., v. Ronzani 7/29, Casalecchio, Italia Fax: +39 (51) 597120
---
[ comp.std.c++ is moderated. Submission address: std-c++@ncar.ucar.edu.
Contact address: std-c++-request@ncar.ucar.edu. The moderation policy
is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]
Technical Details
Message-ID:
<martelli.814174800@cadlab>Path:
arc1-ca.pugleaf.net!128.32.155.1!mattReferences:
<JLM.95Oct12202250@ludo.two-oo-one.fr> <u9burle2pv.fsf@yorick.cygnus.com> <45skdo$cm4@engnews2.Eng.Sun.COM> <45sl3a$coc@engnews2.Eng.Sun.COM> <9510161109.AA08959@slsvgqt.lts.sel.alcatel.de> <damian.813960961@molly.cs.monash.edu.au> <4638jp$ef4@fsgm01.fnal.gov>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!128.32.155.1!matt From: martelli@cadlab.cadlab.it (Alex Martelli) Newsgroups: comp.std.c++ Subject: Re: Q: is A a = 100; equivalent to A a (100); ? Date: 20 Oct 1995 16:38:04 GMT Organization: Cad.Lab Spa, Bologna, Italia Approved: matt@physics2.Berkeley.EDU (Matt Austern) Message-ID: <martelli.814174800@cadlab> References: <JLM.95Oct12202250@ludo.two-oo-one.fr> <u9burle2pv.fsf@yorick.cygnus.com> <45skdo$cm4@engnews2.Eng.Sun.COM> <45sl3a$coc@engnews2.Eng.Sun.COM> <9510161109.AA08959@slsvgqt.lts.sel.alcatel.de> <damian.813960961@molly.cs.monash.edu.au> <4638jp$ef4@fsgm01.fnal.gov> NNTP-Posting-Host: physics2.berkeley.edu