const challenge

Janice Caron caron800 at googlemail.com
Tue Feb 5 00:23:00 PST 2008


On 04/02/2008, Russell Lewis <webmaster at villagersonline.com> wrote:
> Janice Caron wrote:
> > On 03/02/2008, Russell Lewis <webmaster at villagersonline.com> wrote:
> >> If we had a opImplicitCast (and it was overloadable), then it would be
> >> pretty easy to implement a template with thunks:
> >
> > It would - but you'd quickly find ambiguities, at which the compiler
> > would also complain, again requiring an explicit cast to keep the
> > compiler happy.
>
> Can you expand on this?

Sure. If one function, f, returned PolysemousContainer(A,B), and
another function, g, was overloaded thus:

    g(A a) { /* do something */ }
    g(B b) { /* do something else */ }

then the expression

    g( f( ) )

would be ambiguous.



More information about the Digitalmars-d mailing list