Boost logo

Boost :

From: Neal Becker (ndbecker2_at_[hidden])
Date: 2005-08-26 12:29:37


I don't understand why this simple test doesn't compile. Any hints?

#include <iostream>
#include <sstream>
#include <boost/archive/binary_oarchive.hpp>
#include <boost/archive/binary_iarchive.hpp>

class rng_t {
public:
  friend class boost::serialization::access;
  // BOOST_SERIALIZATION_SPLIT_MEMBER()

  template<class Archive>
  inline void save (Archive &ar, const unsigned int) const {
    for (int j = 0; j < 10; ++j)
      // ar << compute(j);
      ar << int(0);
  }

  template<class Archive>
  inline void load (Archive &ar, const unsigned int) {
  }

  template<class Archive>
  void serialize(Archive & ar, const unsigned int file_version) {
    boost::serialization::split_member(ar, *this, file_version);
  }
};
void getstate (const rng_t& rng) {
  std::ostringstream os;
  boost::archive::binary_oarchive oa(os);
  oa << rng;
}

void setstate (rng_t& rng, std::string& st) {
  std::istringstream is (st);
  boost::archive::binary_iarchive ia (is);
  ia >> rng;
}
g++ -c test.cc
test.cc: In member function ‘void rng_t::save(Archive&, unsigned int) const
[with Archive = boost::archive::binary_oarchive]’:
/usr/include/boost/serialization/access.hpp:93: instantiated from ‘static
void boost::serialization::access::member_save(Archive&, T&, unsigned int)
[with Archive = boost::archive::binary_oarchive, T = const rng_t]’
/usr/include/boost/serialization/split_member.hpp:43: instantiated from
‘static void boost::serialization::detail::member_saver<Archive,
T>::invoke(Archive&, const T&, unsigned int) [with Archive =
boost::archive::binary_oarchive, T = rng_t]’
/usr/include/boost/serialization/split_member.hpp:69: instantiated from
‘void boost::serialization::split_member(Archive&, T&, unsigned int) [with
Archive = boost::archive::binary_oarchive, T = rng_t]’
test.cc:25: instantiated from ‘void rng_t::serialize(Archive&, unsigned
int) [with Archive = boost::archive::binary_oarchive]’
/usr/include/boost/serialization/access.hpp:109: instantiated from ‘static
void boost::serialization::access::serialize(Archive&, T&, unsigned int)
[with Archive = boost::archive::binary_oarchive, T = rng_t]’
/usr/include/boost/serialization/serialization.hpp:81: instantiated from
‘void boost::serialization::serialize(Archive&, T&, unsigned int) [with
Archive = boost::archive::binary_oarchive, T = rng_t]’
/usr/include/boost/serialization/serialization.hpp:140: instantiated from
‘void boost::serialization::serialize_adl(Archive&, T&, unsigned int) [with
Archive = boost::archive::binary_oarchive, T = rng_t]’
/usr/include/boost/archive/detail/oserializer.hpp:147: instantiated from
‘void boost::archive::detail::oserializer<Archive,
T>::save_object_data(boost::archive::detail::basic_oarchive&, const void*)
const [with Archive = boost::archive::binary_oarchive, T = rng_t]’
test.cc:37: instantiated from here
test.cc:16: error: no match for ‘operator<<’ in ‘ar << 0’
/usr/include/boost/archive/detail/interface_oarchive.hpp:84: note:
candidates are: Archive&
boost::archive::detail::interface_oarchive<Archive>::operator<<(T&) [with T
= int, Archive = boost::archive::binary_oarchive]


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk