given a class
struct {
int a1;
bool a2;
...
char* a500;
...
char a10000;
}
I want to print or stream out
It's not possible (see the other answers).
One workaround for this is to use automatic code generation. You write the field definitions in a file and then generate the .h and .cpp files from it. I used this for a code which had around 100 classes with lots of fields. It was able to generate the code for sending them to streams (mostly debugging) and for socket communication. It's very reliable (never had to test any of those functionalities), but since it's not pure C++ it might not be the solution for you.