test_polymorphic_A.cpp 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
  2. // test_polymorphic_A.cpp
  3. // (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
  4. // Use, modification and distribution is subject to the Boost Software
  5. // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  6. // http://www.boost.org/LICENSE_1_0.txt)
  7. #include "test_polymorphic_A.hpp"
  8. #include <boost/serialization/nvp.hpp>
  9. #include "A.hpp"
  10. #include "A.ipp"
  11. data::data() :
  12. a(new A)
  13. {}
  14. data::~data(){
  15. delete a;
  16. }
  17. bool data::operator==(const data & rhs) const {
  18. return * (a) == *(rhs.a);
  19. }
  20. #if 0 // this method fails with msvc 6.0 and borland
  21. // now we can define the serialization for class A
  22. template<class Archive>
  23. void data::serialize(Archive & ar, const unsigned int /* file_version */){
  24. ar & BOOST_SERIALIZATION_NVP(a);
  25. }
  26. // without the explicit instantiations below, the program will
  27. // fail to link for lack of instantiantiation of the above function
  28. // note: the following failed to fix link errors for vc 7.0 !
  29. #include <boost/archive/polymorphic_oarchive.hpp>
  30. template void data::serialize<boost::archive::polymorphic_oarchive>(
  31. boost::archive::polymorphic_oarchive & ar,
  32. const unsigned int file_version
  33. );
  34. #include <boost/archive/polymorphic_iarchive.hpp>
  35. template void data::serialize<boost::archive::polymorphic_iarchive>(
  36. boost::archive::polymorphic_iarchive & ar,
  37. const unsigned int file_version
  38. );
  39. #endif
  40. // so use this
  41. void data::serialize(boost::archive::polymorphic_oarchive & ar, const unsigned int /* file_version */){
  42. ar & BOOST_SERIALIZATION_NVP(a);
  43. }
  44. void data::serialize(boost::archive::polymorphic_iarchive & ar, const unsigned int /* file_version */){
  45. ar & BOOST_SERIALIZATION_NVP(a);
  46. }