예제 #1
0
inline
void CEREAL_SAVE_FUNCTION_NAME(Archive &ar, boost::variant<VariantTypes...> const &variant) {
    int32_t which = variant.which();
    ar(CEREAL_NVP_("which", which));
    variant_detail::variant_save_visitor<Archive> visitor(ar);
    variant.apply_visitor(visitor);
}
예제 #2
0
    void serialize_vc6(
        SF::Archive &                                       ar, 
        boost::variant< BOOST_VARIANT_ENUM_PARAMS(T) > &    v,
        const unsigned int)
    {
        if (ar.isWrite())
        {
            ar & int(v.which());
            VariantSerializer variantSerializer(ar);
            v.apply_visitor(variantSerializer);
        }
        else
        {
            int which = 0;
            ar & which;
            
            typedef BOOST_DEDUCED_TYPENAME 
                boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)>::types types;

            if(which >=  boost::mpl::size<types>::value)
            {
                RCF::Exception e( 
                    RCF::_RcfError_VariantDeserialization(
                        which, 
                        boost::mpl::size<types>::value), 
                    "boost::variant mismatch");

                RCF_THROW(e);
            }

            VariantDeserializer<types>::load(ar, which, v);
        }
    }
예제 #3
0
 //! Saving for boost::variant
 template <class Archive, typename... VariantTypes> inline
 void save( Archive & ar, boost::variant<VariantTypes...> const & variant )
 {
   int32_t which = variant.which();
   ar( _CEREAL_NVP("which", which) );
   binary_detail::variant_save_visitor<Archive> visitor(ar);
   variant.apply_visitor(visitor);
 }
예제 #4
0
파일: variant.hpp 프로젝트: imos/icfpc2015
void save(
    Archive & ar,
    boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)> const & v,
    unsigned int /*version*/
){
    int which = v.which();
    ar << BOOST_SERIALIZATION_NVP(which);
    typedef typename  boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)>::types types;
    variant_save_visitor<Archive> visitor(ar);
    v.apply_visitor(visitor);
}