|
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