|
Boost : |
From: Tiago da Silva (besbatti_at_[hidden])
Date: 2008-07-14 22:21:55
Hi there,
I am having some serious problems when trying to instantiate either a
boost::archive::xml_oarchive or a boost::archive::text_oarchive: everytime I
receive an
"Unhandled exception at XXX (msvcr90d.dll) in XXX : Access violation writing
location"
I have simplified a test case up to this:
structure I want to save (in whatever.h):
typedef
struct s_pt
{
int x;
int y;
bool operator< (const struct s_pt &spt2) const
{
return (x < spt2.x) && (y < spt2.y);
}
bool operator== (const struct s_pt &spt2) const
{
return (x == spt2.x) && (y == spt2.y);
}
template<class Archive> // turns into a serializable
component
void serialize(Archive &ar, const unsigned int version)
{
using boost::serialization::make_nvp;
ar & make_nvp("x", x);
ar & make_nvp("y", y);
}
}
POINT2D;
saving routine in main.cpp
std::ofstream ofs("savedProject.imag3d");
boost::archive::xml_oarchive oa(ofs);
const structs::POINT2D p = {111, 222};
oa << boost::serialization::make_nvp("p2d", p);
but I get this error in
boost::archive::xml_oarchive oa(ofs);
I have tried already both xml_oarchive and text_oarchive... but the demo.cpp
provided by
http://www.boost.org/doc/libs/1_35_0/libs/serialization/doc/index.html
involving the bus routes works!!!
what am I doing wrong???
I use Visual Studio 2008.
Thanks in advance,
Tiago
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk