Eigenpoll : D wish list : opCast overloading 

to cast some types to other types:

alias char[] string;

class MyClass
{
string m_sVar;

void opCast(inout string Value)//cast this class to char[]
{
return m_sVar;
}

void opCast(inout int Value)//cast this class to int
{
return atoi(cast(char*)m_sVar);
}
}


So, before casting with the cast(...) operator the compiler must check whether the type contains a casting operator for that type and if so use it to cast.


Report this item for cleanup