const challenge

Russell Lewis webmaster at villagersonline.com
Mon Feb 4 09:32:04 PST 2008


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?

Another (less elegant) solution to this would be to allow overloaded 
opCast().  You could, of course, just access the underlying fields in 
the struct, but that seems less than desirable.  I could imagine an 
"OptionalInvariant" template which held two thunks, one of which would 
produce the invariant version, and one which would produce the variant 
version.



More information about the Digitalmars-d mailing list