cast a LinkSeq

Qian Xu quian.xu at stud.tu-ilmenau.de
Mon Apr 6 09:31:32 PDT 2009


Hi All,

can I cast a LinkSeq from inherited type to base type?

------------------------ code --------------------------
   class Fruit {}
   class Apple: Fruit {}

   auto apples = new LinkSeq!(Apple);
   apples.append(new Apple);
   assert(apples !is null);
   assert(apples.length == 1);
   
   auto fruits = cast(LinkSeq!(Fruit))(apples);
   assert(fruits !is null); // <--- failed
   assert(fruits.length == 1);   
------------------------ code --------------------------


--Qian



More information about the Digitalmars-d mailing list