Boost logo

Boost :

From: Kevin S. Van Horn (Kevin.VanHorn_at_[hidden])
Date: 2002-10-16 10:18:30


A Mojo-enabled class X has ctors

  X(X&);
  X(mojo::constant<X>);
  X(mojo::temporary<X>);

but does NOT have a ctor

  X(X const &);

Now, section 12.8, paragraph 1 of the Standard states

"A class object can be copied in two ways, by initialization (12.1, 8.5),
including for function argument passing (5.2.2) and for function value
return (6.6.3), and by assignment (5.17). Conceptually, THESE TWO
OPERATIONS ARE IMPLEMENTED BY A COPY CONSTRUCTOR (12.1) and COPY
ASSIGNMENT OPERATOR (13.5.3)."

(Emphasis added.) Section 12.1, paragraph 10 defines a copy ctor:

"A copy constructor for a class X is a constructor with a first parameter
of type X& or of type const X&."

This implies that to return an rvalue of type X from a function, or to
pass an rvalue as a function argument that is to be of type X, a
constructor X(const X&) must exist and be accessible, since a copy ctor us
used to return or pass the arguments, this ctor must take X& or X const &,
and the X& form cannot be used with temporaries.

But mojo-enabled classes don't have X const & ctors. Oops.

But neither does auto_ptr<T>! So either there's a flaw in my reasoning,
or there's a flaw in the Standard.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk