|
Boost Users : |
From: cheesy4poofs (cheesy4poofs_at_[hidden])
Date: 2006-02-02 16:23:06
I've read over the compile time trap section of the docs, but I still can't
get my serialization code to compile. The code to save my std::map
compiles, but the code to load the map asserts on the compile. As far as I
can tell, I'm not doing anything wrong (save with const ref, load with
non-const ref).
I will try to summarize my serialization code below:
#include <boost/archive/text_oarchive.hpp>
#include <boost/archive/text_iarchive.hpp>
#include <boost/serialization/map.hpp>
#include <boost/serialization/access.hpp>
struct DLL_EXPORT Node
{
friend class boost::serialization::access;
unsigned int handle; // handle of current object
std::string name; // name of object
std::string value; // optional value of object
template <typename Archive>
void serialize(Archive& ar, const unsigned int version)
{
ar & handle;
ar & name;
ar & value;
}
};
class DLL_EXPORT Manager
{
// manager node adds a few extra things used in management of each
object
struct ManagerNode : public Node
{
friend class boost::serialization::access;
private:
template <typename Archive>
void serialize(Archive& ar, const unsigned int version)
{
// serialize base class information
ar & boost::serialization::base_object <Node>
(*this);
}
};
NodeMap * _nodes;
// this method compiles fine
void save(const std::string & filename)
{
std::ofstream outFile;
outFile.open(filename.c_str(), std::ios::binary);
boost::archive::text_oarchive archiveFile(outFile);
const NodeMap * const n = _nodes;
archiveFile << *n;
}
// fails on compile with STATIC_ASSERTION_FAILURE
void load(const std::string & filename)
{
std::ifstream inFile;
inFile.open(filename.c_str(), std::ios::binary);
boost::archive::text_iarchive archiveFile(inFile);
_nodes->clear();
archiveFile >> *_nodes;
}
};
This is on Windows XP using Visual Studio 7.1. The errors start like this:
..\API\inc\boost\archive\detail\iserializer.hpp(557) : error C2027: use of
undefined type 'boost::STATIC_ASSERTION_FAILURE<x>'
with
[
x=false
]
..\API\inc\boost\archive\detail\iserializer.hpp(557) : see reference
to class template instantiation 'boost::STATIC_ASSERTION_FAILURE<x>' being
compiled
with
[
x=false
]
..\API\inc\boost\archive\basic_text_iarchive.hpp(64) : see reference
to function template instantiation 'void
boost::archive::load<Archive,T>(Archive &,T &)' being compiled
with
[
Archive=boost::archive::text_iarchive,
T=const unsigned int
]
..\API\inc\boost\archive\text_iarchive.hpp(64) : see reference to
function template instantiation 'void
boost::archive::basic_text_iarchive<Archive>::load_override<T>(T &,int)'
being compiled
** snipped for brevity **
Any help would be greatly appreciated.
Scott
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