#include #include #include /////////////////////////////////////////// Singleton class class C { int x,y,z; C() : x(1),y(2),z(3) {} friend class boost::serialization::access; template void serialize(A &a,unsigned v) { a & x & y & z; } //public: //<-- won't compile unless this is public ~C() {} public: static C & Instance() { static C c; return c; } }; ///////////////////////////////////////////////////////////// int main() { // create and open a character archive for output std::ofstream ofs("filename"); boost::archive::text_oarchive oa(ofs); oa << C::Instance(); }