Lionello Lunesu wrote:
> 
> "Robert Fraser" <[email protected]> wrote in message
> news:[email protected]...
>> Lionello Lunesu wrote:
>>>
>>> "bearophile" <[email protected]> wrote in message
>>> news:[email protected]...
>>>> From the last C#:
>>>> http://codepad.org/kQgbwAqJ
>>>>
>>>> Bye,
>>>> bearophile
>>>
>>> Lionello likes this
>>
>> In D if you want to treat a Template!(SomeClass) as a
>> Template!(Object), it's as easy as "cast(Template!(Object))
>> cast(void*) x"
> 
> Does not work for interfaces though.
> 
> L.

Hell, it's not even safe.

class Template(T)
{
    static T instance;
    final T getInstance() { return instance; }
}

Or

class Template(T)
{
    static if( is( T == SomeClass ) )
    {
        bool boom() { return true; }
    }
    void stuff();
}

(cast(Template!(Object)) cast(void*) new Template!(SomeClass)).stuff();

Reply via email to