object.factory with template classes for serializing subclasses automatically
timotheecour
thelastmammoth at gmail.com
Mon Sep 10 21:47:36 PDT 2012
> Also, now that I think about it, why couldn't you do this?
> (it's equivalent):
>
> auto serialize(T)(T a) {
> auto c = cast(SerializerBase) new Serializer!T;
> return c.serialize(a);
> }
that won't work with my example:
class A{}
class B:A{int x;}
A a=new B;
auto c=serialize(a); => T is A, but we want B so that
serialization includes field x.
More information about the Digitalmars-d-learn
mailing list