Boost logo

Boost Users :

Subject: Re: [Boost-users] [serialization] : compile problem
From: Robert Ramey (ramey_at_[hidden])
Date: 2011-08-20 13:55:02


Kaz wrote:
> Hi All,
> I am trying to compile this code to test boost serialization, however
> I am getting this error
>
> Error 5 error C2664: 'boost::mpl::assertion_failed' : cannot convert
> parameter 1 from 'boost::mpl::failed
> ************boost::serialization::is_wrapper<T>::* ***********' to
> 'boost::mpl::assert<false>::type' c:\program files
> (x86)\boost\boost_1_46_1\boost\archive\basic_xml_oarchive.hpp 92
>
> I am using boost 1.46.1, visual studio c++ 2010 express.
>
> Any help will be appreciated.
>
> Thanks,
> Kaz
>
> //-----------------------------------------------------------------------------------------------------------
>
> #include <string>
> #include <boost/serialization/vector.hpp>
> #include <boost/serialization/list.hpp>
> #include <boost/archive/xml_iarchive.hpp>
> #include <boost/archive/xml_oarchive.hpp>
> #include <boost/archive/tmpdir.hpp>
>
> #include <fstream>
>
>
> class Base
> {
> friend class boost::serialization::access;
> template<typename archive>
> void serialize( archive& ar, const unsigned int version )
> {
> ar &
> BOOST_SERIALIZATION_NVP(a) &
> BOOST_SERIALIZATION_NVP(c) &
> BOOST_SERIALIZATION_NVP (strBase);
> }
>
>
> public:
> Base( int a_arg, char c_arg ) : a( a_arg ), c ( c_arg )
> { strBase = "This is base"; }
>
> int a;
> char c;
> std::string strBase;
> };
>
> //-------------------------------------
> BOOST_SERIALIZATION_ASSUME_ABSTRACT(Base)
> //-------------------------------------

One obvious problem is that it seems that the above class is intended to be
an abstract base clas but it has no virtual function - hence, it cannot be
an abstract base class. I'm guessing that the library is detecting this
and failing to compile. Is there not some sort of comment in the source
code at the point where the mpl assert is called? If so, what does it say?

Robert Ramey


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