I've got the classes:
struct A { // has no pointer members, POD - it's fine
int a, b;
char c;
};
struct B { // has no pointer members, but not POD - it's still fine
int a, b;
std::string s;
};
struct C { // has pointer members, it's not fine
int a,b;
char* cs;
};
I need to detect in compile time if any class has the properties of struct C, i.e. has pointers as members.
Short reasoning: I need to assure a user-defined type can be safely serialized and deserialized to some buffer by copying or assignment (e.g. struct A) or by providing user-defined serialize() and deserialize() methods in the class (e.g. struct B and struct c).
If B or C do not have these methods implemented, then compilation should fail, but if A does not have the methods, then the compilation should succeed.
Aucun commentaire:
Enregistrer un commentaire