🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c++
Article #2247

Re: Q: is A a = 100; equivalent to A a (100); ?

#2247
From: David Sachs
Date: Thu, 19 Oct 1995 04:08
34 lines
2117 bytes
matt@godzilla.EECS.Berkeley.EDU (Matt Austern) writes:

>In article <4638jp$ef4@fsgm01.fnal.gov> b91926@fsgm01.fnal.gov (David Sachs) w
rites:

>> X x(a) uses higher priority conversion by overloading rules
>> 
>> X x=a uses X(a.operator X&)

>Sort of.  If a is of class A, if the copy constructor X::X(const X&)
>exists, and if the converting constructor X::X(const A&) exists and
>isn't qualified as explicit, then "X x(a)" simply invokes the
>converting constructor while "X x=a" invokes the converting
>constructor and then the copy constructor.

>Section 12.6 of the working paper explains this in detail.  The rest
>of chapter 12 is somewhat relevant too.

If X had a constructor X(A&), there might be some ambiguity, but
suppose X has a constructor X(B&), where B is a unique base class of
A.

Then X x(a); means X X(B&(a)); as trying X(a.operator X&()) would use
a lower priority user conversion.

X x = a; should use the direct conversion function.
-- 
** The Klingons' favorite food was named by the first earthling to see it **
David Sachs - Fermilab, HPPC MS369 - P. O. Box 500 - Batavia, IL 60510
Voice: 1 708 840 3942      Deparment Fax: 1 708 840 3785
---
[ 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: <463tln$hmm@fsgm01.fnal.gov>
Path: arc1-ca.pugleaf.net!in1.uu.net!bounce-back
References: <damian.813960961@molly.cs.monash.edu.au> <4638jp$ef4@fsgm01.fnal.gov> <MATT.95Oct18111956@godzilla.EECS.Berkeley.EDU>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!in1.uu.net!bounce-back
Date: 19 Oct 95 04:08:08 GMT
Approved: fjh@cs.mu.oz.au
From: b91926@fsgm01.fnal.gov (David Sachs)
Newsgroups: comp.std.c++
Subject: Re: Q: is A a = 100; equivalent to A a (100); ?
X-Original-Date: 18 Oct 1995 17:04:39 -0500
Organization: FERMILAB, Batavia, IL
Message-ID: <463tln$hmm@fsgm01.fnal.gov>
References: <damian.813960961@molly.cs.monash.edu.au> <4638jp$ef4@fsgm01.fnal.gov> <MATT.95Oct18111956@godzilla.EECS.Berkeley.EDU>
Reply-To: sachs@fnal.fnal.gov
X-Newsreader: NN version 6.5.0 #4 (NOV)
X-Auth: PGPMoose V1.1 PGP comp.std.c++
 iQBFAgUBMIXPROEDnX0m9pzZAQEoYQF7B6pEdHUvLEPo5vEzV1KCft0pQRrs9T+p
 lMAdh0eD31pSkfD4dn+xgRY4mmVQr+61
 =P8VD