I just wrote this, it works perfectly, but I don't know what to make of it in terms of what the concept means...
I just wrote this, it works perfectly, but I don't know what to make of it in terms of what the concept means...
each class implements its own specialized serialization, they inherit many common methods from this class and any loaded resources are held in a static hash implemented in the base serialization class.
I don't know if this is the CRTP actually -- it looks similar-ish, but CRTP is when a a derived class inherits from a base which takes the derived class as a template parameter; here, unless I misread (which could be, I'm not sure what the language in question here is... C#? Java?), you have a templates class that requires its template argument to be of the same type.
OP, which language is this?
It would seem on the surface to be infinitely recursive, unless at some point it a default argument kicks in and bottoms out the recursion -- That, or it doesn't actually recurse at all and only goes 2 levels deep. But its hard to say -- templates/generics in any language get weird.
Nevermind, I see how it goes now, but I remain unconvinced that this is CRTP.
public class SomeData : SerializedData<SomeData> ...
It's a CRGC (curiously recurring generic constraint), not CRTP. I don't know if anyone's ever formally called it that, but that's what I call it.
Like unbird says, using the CRGC requires that the parameter use a CRTP.
Yes, this is the case, this class is meant to be inherited by other classes that need to be serialized and they must set themselves as the template parameter. Though it is true that this class declaration by itself does not force its data to inherit from it, it could be the same class with the same type, but that would be pretty pointless in my project.
It goes just as unbird said.