Boost logo

Boost Users :

From: Diane (dbutton_at_[hidden])
Date: 2008-09-03 22:11:50


Robert Ramey <ramey <at> rrsd.com> writes:
> Not at all true. serialize is called at each point. If ..SPLIT is used
> then a standard serial.ize function is inserted whch calls save/load
> for that (and only that) structure.
>
> Robert Ramey
>

Awesome, thanks!

I found a similar piece of code in greg_serialize.hpp that I'm trying to work
from, but I get compile errors even if I'm not doing anything in save/load:

error: call of overloaded `serialize(boost::archive::text_iarchive&,
MYSTRSTRUCT&, const boost::serialization::version_type&)' is ambiguous

Is there any chance you can spot what I'm doing wrong in my code?

typedef struct MYSTRSTRUCT
{
   char *chstar;
} MYSTRSTRUCT;

BOOST_SERIALIZATION_SPLIT_FREE(MYSTRSTRUCT)

template<class Archive>
inline void serialize(Archive & ar,
                      MYSTRSTRUCT & d,
                      const unsigned int file_version)
{
  split_free(ar, d, file_version);
}

template<class Archive>
void save(Archive & ar,
          const MYSTRSTRUCT & d,
          unsigned int /* version */)
{
  int i = strlen(d.chstar);
}

template<class Archive>
void load(Archive & ar,
          MYSTRSTRUCT & d,
          unsigned int /*version*/)
{
   int i;
}

And then it's used in serialize() for the struct that contains a MYSTRSTRUCT:
    ar & it.strstruct

Here's the full compiler output:
boost_1_36_0/boost/serialization/serialization.hpp: In function `void
boost::serialization::serialize_adl(Archive&, T&, unsigned int) [with Archive =
boost::archive::text_iarchive, T = MYSTRSTRUCT]':
boost_1_36_0/boost/archive/detail/iserializer.hpp:152: instantiated from `void
boost::archive::detail::iserializer<Archive,
T>::load_object_data(boost::archive::detail::basic_iarchive&, void*, unsigned
int) const [with Archive = boost::archive::text_iarchive, T = MYSTRSTRUCT]'
serialize4.cpp:80: instantiated from here
boost_1_36_0/boost/serialization/serialization.hpp:133: error: call of
overloaded `serialize(boost::archive::text_iarchive&, MYSTRSTRUCT&, const
boost::serialization::version_type&)' is ambiguous
boost_1_36_0/boost/serialization/serialization.hpp:73: note: candidates are:
void boost::serialization::serialize(Archive&, T&, unsigned int) [with Archive =
boost::archive::text_iarchive, T = MYSTRSTRUCT]
serialize4.cpp:337: note: void boost::serialization::serialize(Archive&,
MYSTRSTRUCT&, unsigned int) [with Archive = boost::archive::text_iarchive]
serialize4.cpp:345: note: void serialize(Archive&, MYSTRSTRUCT&, unsigned int)
[with Archive = boost::archive::text_iarchive]
boost_1_36_0/boost/serialization/serialization.hpp: In function `void
boost::serialization::serialize_adl(Archive&, T&, unsigned int) [with Archive =
boost::archive::text_oarchive, T = MYSTRSTRUCT]':
boost_1_36_0/boost/archive/detail/oserializer.hpp:144: instantiated from `void
boost::archive::detail::oserializer<Archive,
T>::save_object_data(boost::archive::detail::basic_oarchive&, const void*
 const [with Archive = boost::archive::text_oarchive, T = MYSTRSTRUCT]'
serialize4.cpp:80: instantiated from here
boost_1_36_0/boost/serialization/serialization.hpp:133: error: call of
overloaded `serialize(boost::archive::text_oarchive&, MYSTRSTRUCT&, const
boost::serialization::version_type&)' is ambiguous
boost_1_36_0/boost/serialization/serialization.hpp:73: note: candidates are:
void boost::serialization::serialize(Archive&, T&, unsigned int) [with Archive =
boost::archive::text_oarchive, T = MYSTRSTRUCT]
serialize4.cpp:337: note: void boost::serialization::serialize(Archive&,
MYSTRSTRUCT&, unsigned int) [with Archive = boost::archive::text_oarchive]
serialize4.cpp:345: note: void serialize(Archive&, MYSTRSTRUCT&, unsigned int)
[with Archive = boost::archive::text_oarchive]

Thanks,
Diane


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