|
Boost Users : |
From: James Vanns (james.vanns_at_[hidden])
Date: 2008-05-30 09:48:49
If this interests anyone - I figured it out. Basically the ordering of the headers included matters:
Before
#include <boost/serialization/map.hpp>
You must add
#include <boost/archive/text_oarchive.hpp>
#include <boost/archive/text_iarchive.hpp>
Then it'll work - even if you don't use the archivers until another unit.
Jim
----- Original Message -----
From: "james vanns" <james.vanns_at_[hidden]>
To: boost-users_at_[hidden]
Sent: Friday, 30 May, 2008 11:03:38 AM GMT +00:00 GMT Britain, Ireland, Portugal
Subject: Compile error when serializing an std::map./
Hi all, with Boost 1.3.5 and g++ 4.2.1 on Linux I get the following compile error from one of the Boost headers:
boost/serialization/utility.hpp:48: error: expected template-name before â<â token
boost/serialization/utility.hpp:48: error: expected `{' before â<â token
boost/serialization/utility.hpp:48: error: expected unqualified-id before â<â token
boost/serialization/utility.hpp:50: error: extra â;â
I am trying to serialize a map like so:
#include <boost/serialization/map.hpp>
using std::map;
struct Resource {
enum ID {
CPU = 0,
RAM,
TMP,
PRMAN
};
static const char* const name[];
};
class ResourceSet {
private:
typedef uint16_t Tally;
typedef Resource::ID RID;
map<RID, Tally> m_resources;
private:
friend class boost::serialization::access;
template<class Archive>
void serialize (Archive &p_ark, const unsigned int p_version);
};
template<class Archive>
void
ResourceSet::serialize (Archive &p_ark, const unsigned int p_version)
{
p_ark & m_resources;
}
So I am wondering why the compiler is spitting out this error? Is this a bug or is this because of the typedefs? Line 48+ from utility.hpp is this:
/// specialization of is_bitwise_serializable for pairs
template <class T, class U>
struct is_bitwise_serializable<std::pair<T,U> >
: public mpl::and_<is_bitwise_serializable<T>,is_bitwise_serializable<U> >
{
};
} // serialization
} // namespace boost
Regards,
Jim Vanns
-- James Vanns Systems Programmer Framestore CFC Ltd. -- James Vanns Systems Programmer Framestore CFC Ltd.
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