I'm not able to use boost::serialization
because it has library dependencies so I'm trying to figure out a way to do it myself. It doesn't matter if that means copying from boost::serialization
.
After reading this answer to a similar question, I had a look at boost/serialization/variant.hpp and found save()
function which is straight forward and understandable for me.
However the load()
function looks more complicated: There is a recursion involving load()
and variant_impl<types>::load()
and a decremented which
parameter.
So apparently the code iterates over each type of the variant in order to convert the int which
into a type.
The rest is beyond me.
I know that boost has lot of code to make it portable so maybe there is a less-portable but easier way to do this?