Implicit type conversion for function calls?

Simen Kjaeraas simen.kjaras at gmail.com
Mon Jul 11 10:15:44 PDT 2011


On Sun, 10 Jul 2011 22:30:34 +0200, Jonathan M Davis <jmdavisProg at gmx.com>  
wrote:

> Well, if you can do it with alias this, then it's possible. If not, then  
> it
> probably isn't. But I don't know what opImplicitCast would give you if  
> alias
> this doesn't (particularly if alias this is working properly; the current
> implementation is buggy enough that whether it works now or not doesn't
> necessarily mean much). I really don't know what would be required to  
> get a
> TypeDef template working properly though. I don't really see any need  
> for such
> a beast personally, so I haven't really looked into it.

Basically, four types of typedef were outlined:

Supertype!T - You may pass T to a function requiring Supertype!T,
   and may assign a T to a Supertype!T, but not vice versa.

Subtype!T - You may pass a Subtype!T to a function requiring T,
   and may assign a Subtype!T to a T, but not vice versa.

Lateraltype!T - Behaves like a T in most ways, but cannot pass a T
   to a function expecting a Lateraltype!T, nor vice versa.

alias - Yeah, you know the one.

All of these have their uses, and currently only alias is in the
language.

-- 
   Simen


More information about the Digitalmars-d-learn mailing list