As for serialization: it should work, yes. But why don't you use the boost::variant visit mechanism to write the actual type contained in this variant?
struct variant_serializer : boost::static_visitor<void> { template <typename T> typename boost::enable_if< boost::is_pod<T>, void>::type operator()( const T & t ) const {
As for shared memory: boost::variant does not perform heap allocation, so you can put it in shared memory just like int , assuming proper synchronization, of course.
Needless to say, as you said, the above is only valid if the variant can only contain POD types.
Marc Mutz - mmutz
source share