object.factory with template classes for serializing subclasses automatically
Chris Cain
clcain at uncg.edu
Mon Sep 10 21:38:00 PDT 2012
On Tuesday, 11 September 2012 at 03:18:40 UTC, timotheecour wrote:
> auto serialize(T)(T a){
> auto
> c=cast(SerializerBase)Object.factory("Serializer!("~typeid(a).to!string~").Serializer");
> return c.serialize(a);
> }
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);
}
More information about the Digitalmars-d-learn
mailing list