Boost logo

Boost Users :

Subject: [Boost-users] [serialization] check_object_versioning(), STATIC_ASSERTION_FAILURE
From: Âèòÿ Èñòîìèí (spiritfire_at_[hidden])
Date: 2010-10-15 05:21:35


Please help, or point me where should i read about it. What is this versioning and why my code was compiled with boost 1.39 will get compilation errors in 1.43?

Code:

#include <list>
#include <boost/serialization/access.hpp>
#include <boost/serialization/level.hpp>
#include <boost/serialization/split_member.hpp>
#include <boost/serialization/tracking.hpp>
#include <boost/serialization/list.hpp>
#include <boost/serialization/variant.hpp>
#include <boost/serialization/version.hpp>
...
typedef boost::variant <__int32, unsigned __int32, std::string, std::wstring > param_t; // note: I've tried to use boost::int32_t and others, result is the same
typedef std::list< param_t > params_list_t;
...

class instruction
{
public:
  ...
private:
  friend class boost::serialization::access; /**< Make accessible private members for boost serialization */

  void save (boost::archive::xml_oarchive& ar, unsigned int version) const;
  void load (boost::archive::xml_iarchive& ar, unsigned int version);
  BOOST_SERIALIZATION_SPLIT_MEMBER()
 
private:
  ...
  params_list_t m_params; /**< List of parameters */
};

BOOST_CLASS_IMPLEMENTATION(instruction, boost::serialization::object_serializable);
BOOST_CLASS_TRACKING(instruction, boost::serialization::track_never)
BOOST_CLASS_IMPLEMENTATION(nvp<instruction>, boost::serialization::object_serializable)
BOOST_CLASS_TRACKING(nvp<instruction>, boost::serialization::track_never)
BOOST_CLASS_VERSION(instruction, 1);

BOOST_CLASS_IMPLEMENTATION(param_t, boost::serialization::object_serializable);
BOOST_CLASS_TRACKING(param_t, boost::serialization::track_never)
BOOST_CLASS_IMPLEMENTATION(nvp<param_t>, boost::serialization::object_serializable)
BOOST_CLASS_TRACKING(nvp<param_t>, boost::serialization::track_never)
BOOST_CLASS_VERSION(param_t, 1)

BOOST_CLASS_VERSION(params_list_t, 1)
BOOST_CLASS_IMPLEMENTATION(nvp<params_list_t>, boost::serialization::object_serializable)
BOOST_CLASS_TRACKING(nvp<params_list_t>, boost::serialization::track_never)
BOOST_CLASS_IMPLEMENTATION(params_list_t, boost::serialization::object_serializable);
BOOST_CLASS_TRACKING(params_list_t, boost::serialization::track_never)

BOOST_CLASS_IMPLEMENTATION(nvp<instructions_list_t>, boost::serialization::object_serializable)
BOOST_CLASS_TRACKING(nvp<instructions_list_t>, boost::serialization::track_never)
BOOST_CLASS_IMPLEMENTATION(instructions_list_t, boost::serialization::object_serializable)
BOOST_CLASS_TRACKING(instructions_list_t, boost::serialization::track_never)

CPP file:
void instruction::save (boost::archive::xml_oarchive& ar, unsigned int version) const
{
  // ...
  ar << BOOST_SERIALIZATION_NVP(m_params); // error is here, all other lines commented
  // ...
}

Error (MS VS2008):
1>d:\Work\manager\third_party\boost\include\boost/archive/detail/check.hpp(78) : error C2027: use of undefined type 'boost::STATIC_ASSERTION_FAILURE<x>'
1> with
1> [
1> x=false
1> ]
1> d:\Work\manager\third_party\boost\include\boost/archive/detail/oserializer.hpp(307) : see reference to function template instantiation 'void boost::archive::detail::check_object_versioning<T>(void)' being compiled
1> with
1> [
1> T=const params_list_t
1> ]
1> d:\Work\manager\third_party\boost\include\boost/archive/detail/oserializer.hpp(525) : see reference to function template instantiation 'void boost::archive::detail::save_non_pointer_type<Archive>::invoke<const T>(Archive &,const T &)' being compiled
1> with
1> [
1> Archive=boost::archive::xml_oarchive,
1> T=const params_list_t
1> ]
1> d:\Work\manager\third_party\boost\include\boost/archive/detail/common_oarchive.hpp(69) : see reference to function template instantiation 'void boost::archive::save<Archive,T>(Archive &,T &)' being compiled
1> with
1> [
1> Archive=boost::archive::xml_oarchive,
1> T=const params_list_t
1> ]
...

This is a first error message place:

template<class T>
inline void check_object_versioning(){
    typedef
        BOOST_DEDUCED_TYPENAME mpl::or_<
            BOOST_DEDUCED_TYPENAME mpl::greater<
                serialization::implementation_level<T>,
                mpl::int_<serialization::object_serializable>
>,
            BOOST_DEDUCED_TYPENAME mpl::equal_to<
                serialization::version<T>,
                mpl::int_<0>
>
> typex;
    // trap attempts to serialize with objects that don't
    // save class information in the archive with versioning.
    BOOST_STATIC_ASSERT(typex::value);
}

I have understanding about what is BOOST_STATIC_ASSERT, but I haven't any ideas about what I'm doing wrong.
Changelog reading between 1.39 and 1.43 hasn't clarified anything.

-- ðåêëàìà -----------------------------------------------------------
Òðè íîâûå ëèíåéêè õîñòèíã-ïëàíîâ - âñ¸ ÷òî íóæíî Âàøåìó ñàéòó!
6 ìåñÿöåâ õîñòèíãà áåñïëàòíî è äîìåí â ïîäàðîê. http://Hvosting.ua


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