Is there a way to serialize automatically enums as int?
- by FireAphis
Hello,
Is there a way to serialize enums automatically as int? Every time I define a new enum and write 
std::stringstream stream;
stream << myenum1;
stream >> myenum2;
the compiler complains that the operators << and  are not defined. Do you know a way to tell the compiler to treat enums as plain int's?
What makes the problem harder is that, actually, the serialization is inside a template. Something like this:
template <typename T>
void serialize(const T& value)
{
    std::stringstream stream;
    stream << value;
}
So I cannot add any casts :(
Maybe I can specialize it somehow?
Thank you.