Boost logo

Threads-Devel :

From: Frank Mori Hess (frank.hess_at_[hidden])
Date: 2008-03-13 13:47:32


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Thursday 13 March 2008 12:20 pm, Anthony Williams wrote:
> When converting from type A to type B, you're only allowed one
> user-defined conversion (UDC). If U has no direct conversion to Y,
> then the chain U->V->W->X->Y has too many UDCs to be considered for
> conversion.

Oh, to be clear I never meant it should try to guess a chain of conversions
for the user.

> >> For this to work, therefore, you'd have to wrap the
> >> internal data with every conversion, otherwise some future<V>s could
> >> be converted to future<W>s, but not others. How did you handle this
> >> case?
> >
> > I'm not sure which case you're thinking of when you say some futures
> > could be converted but not others?
>
> If your future<V> really stores a U, you can't convert this to a

No, it really stores a V. It just acts as an observer and constructs the V
from the U when the U is ready.

> future<W> (since U is not convertible to W) unless you wrap the stored
> U in a layer that converts to a V.
>
> > Wrapping the internal data with every conversion
> > sounds roughly like what I did. I tried to make the conversions for
> > futures behave just like the values they are wrapping. So in the example
> > you give, the value for the future<Y> will be created by going through
> > all the conversions U to V to W to X to Y. U does not have to be
> > directly convertible to Y.
>
> OK. I understand the approach, I'm just not sure I like it --- you
> started with a future<U>, and somehow you've got a future<Y> by adding
> a load of intermediate layers.

A more verbose example Just to make sure I've been clear:

future<U> fu;
// ...
future<V> fv = fu;
future<W> fw = fv;
future<X> fx = fw;
future<Y> fy = fx;

When fu becomes ready, fy becomes ready with the same value as if you had done

future<U> fu;
// ...
U u = fu;
V v = u;
X x = v;
Y y = x;

- --
Frank
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)

iD8DBQFH2Wi15vihyNWuA4URApoqAKC9Qpp4bhXc3HPFYXIwG4F5XvBunQCff7ah
K3d8GDfcAiQlG9nm+tZ0zPA=
=wpe7
-----END PGP SIGNATURE-----


Threads-Devel list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk