Topic: explicit and a possible defect report ... and a RFI
Author: Valentin.Bonnard@free.fr (Valentin Bonnard)
Date: Mon, 12 Feb 2001 17:04:52 GMT Raw View
gennaro_prota@my-deja.com wrote:
> Clause 12.3.1 of the standard provides the following rules/definitions:
> 3. A copy-constructor (12.8) is a converting constructor. An implicitly-
> declared copy constructor is not an explicit constructor; it may be
> called for implicit type conversions.
Hum. This reminds me of something I have never quite understoud:
- What's a converting copy constructor ?
- What's a converting default constructor ?
Are these animals the results of uncontrolled C++ genetic
experiments, the inventions of a psychopathic committee
member, or useful tools that are simply beyond my C++
knowledge ?
--
Valentin Bonnard
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.research.att.com/~austern/csc/faq.html ]
[ Note that the FAQ URL has changed! Please update your bookmarks. ]
Author: jpotter@falcon.lhup.edu (John Potter)
Date: Mon, 12 Feb 2001 21:41:53 GMT Raw View
On Mon, 12 Feb 2001 17:04:52 GMT, Valentin.Bonnard@free.fr (Valentin
Bonnard) wrote:
> gennaro_prota@my-deja.com wrote:
>
> > Clause 12.3.1 of the standard provides the following rules/definitions:
>
> > 3. A copy-constructor (12.8) is a converting constructor. An implicitly-
> > declared copy constructor is not an explicit constructor; it may be
> > called for implicit type conversions.
>
> Hum. This reminds me of something I have never quite understoud:
Half seriously:
12.3.1/1 defines a converting ctor as one without the
explicit word and usable with one arguement.
> - What's a converting copy constructor ?
struct S { S (); S (S const&); };
struct T : S { int t; };
T t;
t.t = 42;
S s(t);
Does the slicing qualify as a conversion? Clause 13 states that there
is no derived to base conversion. I guess it is a converting ctor
because it performs the standard identity conversion.
> - What's a converting default constructor ?
There is no such thing, but it may still be explicit. Maybe because:
struct S { int s; explicit S (int i = 42); };
The one constructor is both a converting ctor and a default ctor.
S s1; // valid
S s2 = 7; // invalid
> Are these animals the results of uncontrolled C++ genetic
> experiments, the inventions of a psychopathic committee
> member, or useful tools that are simply beyond my C++
> knowledge ?
All of the above?
What does explicit mean on a ctor with two required parameters mean?
I think, nothing. It is easiest to just allow it on any ctor?
John
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.research.att.com/~austern/csc/faq.html ]
[ Note that the FAQ URL has changed! Please update your bookmarks. ]