[contest] Is a Cow an animal ++

BCS none at anon.com
Wed Sep 29 05:55:46 PDT 2010


Hello Simen,

> bearophile <bearophileHUGS at lycos.com> wrote:
> 
>> The fourth C++ version contains a line that I am am not even sure how
>> to  translate to D (maybe there is a workaround with template
>> constraints): (void) static_cast<My_kind *>((Kind *) 0);
>> 
> This is a static assert of sorts. Basically, the function will only
> compile if Kind is a subtype of My_kind. In D, you would use
> is( Kind : My_kind ), where Kind and My_Kind are interfaces
> Here's mine ( 8/11 at compile-time, the remaining at runtime ):
> http://ideone.com/6WlFJ
> I don't think it's possible to make it better than that in D without,
> as you say, for instance type states.


The given test as is might be all catchable but add loops and references 
into the picture and I think it turns into the halting problem.
-- 
... <IXOYE><





More information about the Digitalmars-d mailing list