James Kanze
10/1/2008 7:35:00 AM
On Sep 30, 12:51 pm, Pete Becker <p...@versatilecoding.com> wrote:
> On 2008-09-30 05:59:23 -0400, James Kanze <james.ka...@gmail.com> said:
> > On Sep 30, 8:27 am, "subramanian10...@yahoo.com, India"
> > <subramanian10...@yahoo.com> wrote:
> >> * James Kanze <james.ka...@gmail.com> wrote:
> >> Suppose I have kept the copy ctor of the element type T as
> >> 'explicit'. Then, can I say that T is still
> >> CopyConstructible ?
> > Apparently, according to the text in the standard. I
> > wouldn't declare a copy constructor explicit, however---I'm
> > not sure what that means, or even what it should mean,
> > logically.
> One implication is this:
> T t0;
> T t1(t0); // OK: explicit copy construction
> T t2 = t0; // error: implicit copy construction
> And that's a very good reason not to do it.
That's what I understand as well. But only as a result of some
discussions in the newsgroups. This means that you can't pass
objects with explicit copy constructors to functions, or return
them from functions, which (IMHO) pretty much makes copying
useless (or irrelevant)---perhaps it would make sense if you
only want to support copy so that you can implement some form of
generic clone function. But even that seems exoteric enough
that I wouldn't use it.
It also means, of course, that an implementation of the standard
library cannot pass the instantiation type by value, or return
it, since the requirements are only that the expression T(t) is
legal, and this is the case even if the copy constructor is
explicit.
--
James Kanze (GABI Software) email:james.kanze@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34