Jump to content
  • Advertisement
Sign in to follow this  

boost serialization to xml has problems

This topic is 3649 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

In a test Win32 console app, the following code throws a boost exception when run:
#include "stdafx.h"
#include <boost/archive/xml_oarchive.hpp>
#include <boost/serialization/nvp.hpp>
#include <fstream>

class SomeClass
	SomeClass() : m_foo(666), m_bar(777.f) {}

	friend class boost::serialization::access;
	template<class Archive>
	void serialize(Archive& archive, const unsigned int version)
		archive & boost::serialization::make_nvp("Foo", m_foo);
		archive & boost::serialization::make_nvp("Bar", m_bar);

	int m_foo;
	float m_bar;

int _tmain(int argc, _TCHAR* argv[])
	SomeClass someClass;
	std::ofstream fileStream("TestFile.object");
	boost::archive::xml_oarchive oa(fileStream);
	oa << boost::serialization::make_nvp("Some Class", someClass);

	return 0;
If I do not use make_nvp, the code doesn't even compile. Switching from xml_oarchive to text_oarchive works without problem. Can someone tell me what I am doing wrong? Thanks

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!