Boost logo

Boost Users :

From: David Kantowitz (david.kantowitz_at_[hidden])
Date: 2007-04-10 23:36:38


I'm having a bit of trouble using boost.serialization with a std::map.
 It seems like there is something simple I'm not doing correctly. I'm
hoping someone can point me in the right direction.
Thanks,
David K.

I'm using VS2005. Here is my test code:

#include <map>
#include <fstream>
#include "boost/serialization/map.hpp"
#include "boost/archive/xml_oarchive.hpp"

std::map<int, int> map1;

int main(int argc, char**argv)
{
  map1[1] = 100;
  std::ofstream os("out.xml");
  boost::archive::xml_oarchive oa(os);
  oa << BOOST_SERIALIZATION_NVP(map1);
}

This is the error:

...boost-win32-1_33_1\include\boost\archive\detail\oserializer.hpp(131)
: error C2027: use of undefined type
'boost::serialization::extended_type_info_null<T>'
        with
        [
            T=std::map<int,int>
        ]
        ...boost-win32-1_33_1\include\boost\archive\detail\oserializer.hpp(128)
: while compiling class template member function 'bool
boost::archive::detail::oserializer<Archive,T>::is_polymorphic(void)
const'
        with
        [
            Archive=boost::archive::xml_oarchive,
            T=std::map<int,int>
        ]
        ...boost-win32-1_33_1\include\boost\archive\detail\oserializer.hpp(264)
: see reference to class template instantiation
'boost::archive::detail::oserializer<Archive,T>' being compiled
        with
        [
            Archive=boost::archive::xml_oarchive,
            T=std::map<int,int>
        ]
        ...boost-win32-1_33_1\include\boost\archive\detail\oserializer.hpp(263)
: while compiling class template member function 'void
boost::archive::detail::save_non_pointer_type<Archive,T>::save_standard::invoke(Archive
&,const T &)'
        with
        [
            Archive=boost::archive::xml_oarchive,
            T=std::map<int,int>
        ]
        ...boost-win32-1_33_1\include\boost\archive\detail\oserializer.hpp(322)
: see reference to class template instantiation
'boost::archive::detail::save_non_pointer_type<Archive,T>::save_standard'
being compiled
        with
        [
            Archive=boost::archive::xml_oarchive,
            T=std::map<int,int>
        ]
        ...boost-win32-1_33_1\include\boost\archive\detail\oserializer.hpp(310)
: while compiling class template member function 'void
boost::archive::detail::save_non_pointer_type<Archive,T>::invoke(Archive
&,const T &)'
        with
        [
            Archive=boost::archive::xml_oarchive,
            T=std::map<int,int>
        ]
        ...boost-win32-1_33_1\include\boost\archive\detail\oserializer.hpp(536)
: see reference to class template instantiation
'boost::archive::detail::save_non_pointer_type<Archive,T>' being
compiled
        with
        [
            Archive=boost::archive::xml_oarchive,
            T=std::map<int,int>
        ]
        ...boost-win32-1_33_1\include\boost\archive\basic_xml_oarchive.hpp(99)
: see reference to function template instantiation 'void
boost::archive::save<Archive,T>(Archive &,const T &)' being compiled
        with
        [
            Archive=boost::archive::xml_oarchive,
            T=std::map<int,int>
        ]
        ...boost-win32-1_33_1\include\boost\archive\detail\interface_oarchive.hpp(78)
: see reference to function template instantiation 'void
boost::archive::basic_xml_oarchive<Archive>::save_override<std::map<_Kty,_Ty>>(const
boost::serialization::nvp<T> &,int)' being compiled
        with
        [
            Archive=boost::archive::xml_oarchive,
            _Kty=int,
            _Ty=int,
            T=std::map<int,int>
        ]
        ...\source1.cpp(14) : see reference to function template
instantiation 'Archive
&boost::archive::detail::interface_oarchive<Archive>::operator
<<<const boost::serialization::nvp<T>>(const
boost::serialization::nvp<T> &)' being compiled
        with
        [
            Archive=boost::archive::xml_oarchive,
            T=std::map<int,int>
        ]


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net