Boost logo

Boost :

From: Kevin S. Van Horn (Kevin.VanHorn_at_[hidden])
Date: 2002-10-16 11:17:47


I'm still struggling to convince myself that Mojo is guaranteed to work by
the conversion rules in the standard. To recap: in a mojo-ized class X we
replace the usual X(X const &) copy ctor with

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

and add conversions

  operator mojo::temporary<X>();

and

  operator mojo::constant<X>() const;

to class X. The crucial point on which this whole edifice stands or falls
is that if we need to copy a temporary of type X, then
X(mojo::temporary(X)) will be called. But there are two possibilities:

A: X([temporary object].operator mojo::temporary<X>())

or

B: X([temporary object].operator mojo::constant<X>()).

I've been looking through the Standard, and I haven't yet been able to
convince myself that overload resolution will choose A over B.

Can anyone explain to me why overload resolution will choose A over B?
Andrei's latest draft claims this is so because temporary<X> is derived
from constant<X>, but I think this is a red herring; as far as I can tell,
inheritance relations only affect overload resolution if you actually have
to do the conversion from derived to base in order to match a parameter
type.


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