Hi, guys!

I have templated classes like this:

class Some(T1) {
  T1 value;
  this(T1 _value){
    value = _value;
  }
}
class Pair(T1, T2) {
  T1 first;
  T2 second;
  this(T1 _first, T2 _second){
    first = _first;
    second = _second;
  }
}

and a lot of serialised data, which I have to read and instantiate into given classes. Serialized data looks like this: 'Some(Pair("df", 5.0))' or 'Pair(Some(true), 11)', i.e. order of structs, its types and inclusion order are unknown at compile time.

I know there are several serialisation libraries, but I found they work only with non-templated classes, like:

class Foo {
  int a;
}

I can read input data and parse it, but have no idea how to construct object of templated class in this situation. Please give a hint.

Reply via email to