std::variant is a replacement of union.
But union can pass over network and receive in another platform(different compiler or arch) safely. Can std::variant do so?
For example, I have two machine A and B. A is windows, MSVC 19.4. B is Linux, gcc(or other compilers, such MSVC 17). I compile the code under A(or B):
std::variant<int, double> v = 1; // holds int.
f.write(&v, sizeof(v));
Can B read correct value using the following code from the same file?
std::variant<int, double> v;
f.read(&v, sizeof(v));
If std::variant couldn't pass over network safely. Are there any library provides one? boost::variant? or maybe to create a customize implemation that act like std::variant?