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.
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@framestore.com> To: boost-users@lists.boost.org 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.
participants (2)
-
James Vanns
-
james.vanns@framestore.com