Boost logo

Boost :

From: David Abrahams (dave_at_[hidden])
Date: 2004-02-11 15:47:23

"Rani Sharoni" <rani_sharoni_at_[hidden]> writes:

> David Abrahams wrote:
>> I think the text has to account for the possibility that the
>> constructor used might be explicit, doesn't it?
> This is true but explicit copy (or copying) constructor is quite useless
> (unless someone will find a way to abuse it for good purpose).

Maybe it's useless, but it's detectable.

> Raoul Gough and I have tried to relax this surprising reference binding
> limitation (i.e. requires copying constroctor) for the favor of wider range
> of cases (e.g. private copy constructor). The suggestion basically says that
> *direct reference binding* is enough for most cases of class rvalue
> bindings.
>>> IMO your suggestion is fully compliant and EDG has bug that confuses
>>> everyone.
>>> I don't have anything else to add to this discussion.
> Maybe some more.
>> Sorry to draw it out, but I don't understand when you say "suggestion"
>> whether you're referring to my suggested text change or the movable
>> class idiom I posted.
> The later.
> For the moveable class Idiom you don't need to revise the standard text
> since Steve Adamczyk already did that ~7 years ago when he removed the copy
> constructor requirement.

I wish you could get EDG, Metrowerks, and Microsoft (and others, I'm
sure, including Peter Dimov) to agree with you. There appears to be
an emerging consensus among implementors that a public non-const copy
ctor is needed.

> You only encountered a bug in EDG which is also inconsistent:
> struct A {
> // private:
> template<typename T>
> A(T const& r) {
> int const* p = &r; // error if T != int -> error if T == A
> p = p;
> }
> private:
> A(A&);
> };
> int f(A const&);
> // template constructor is
> // enough for the "illusive coping"
> int x = f(A(10)); // compiled fine using EDG and GCC
> Making the template *converting* constructor private will trigger access
> error for both EDG and GCC although they don't actually call it.

That in itself
> VC rejected this code and has open bug for this issue.
> Again DR #391: <Q> J. Stephen Adamczyk replied that the reason for changing
> "a copy constructor" to "a constructor" was to allow for member template
> *converting* constructors.</Q>
> In your moveable implementation the converting constructor (i.e. X(ref)) is
> as good as template converting constructor from overloading pov which makes
> your code *fully compliant* within the current standard
> text. Cheers!

Whoa. Is that different from MoJo?
And how can I understand what you're saying well enough to convince
implementors that I'm right?

Dave Abrahams
Boost Consulting

Boost list run by bdawes at, gregod at, cpdaniel at, john at