1 /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 2 // test_private_ctor.cpp 3 4 // (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . 5 // Use, modification and distribution is subject to the Boost Software 6 // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at 7 // http://www.boost.org/LICENSE_1_0.txt) 8 9 #include <sstream> 10 11 #include "test_tools.hpp" 12 13 #include <boost/serialization/vector.hpp> 14 15 #include <boost/archive/text_iarchive.hpp> 16 #include <boost/archive/text_oarchive.hpp> 17 18 class V { 19 private: 20 friend int test_main(int /* argc */, char * /* argv */[]); 21 friend class boost::serialization::access; 22 int m_i; V()23 V() : 24 m_i(0) 25 {} 26 template<class Archive> serialize(Archive & ar,unsigned)27 void serialize(Archive& ar, unsigned /*version*/) 28 { 29 ar & m_i; 30 } 31 public: ~V()32 ~V(){} operator ==(const V & v) const33 bool operator==(const V & v) const { 34 return m_i == v.m_i; 35 } 36 }; 37 test_main(int,char * [])38int test_main(int /* argc */, char * /* argv */[]) 39 { 40 std::stringstream ss; 41 const V v; 42 { 43 boost::archive::text_oarchive oa(ss); 44 oa << v; 45 } 46 V v1; 47 { 48 boost::archive::text_iarchive ia(ss); 49 ia >> v1; 50 } 51 BOOST_CHECK(v == v1); 52 53 const V *vptr = & v; 54 { 55 boost::archive::text_oarchive oa(ss); 56 oa << vptr; 57 } 58 V *vptr1; 59 { 60 boost::archive::text_iarchive ia(ss); 61 ia >> vptr1; 62 } 63 BOOST_CHECK(*vptr == *vptr1); 64 65 return EXIT_SUCCESS; 66 } 67