scoped_ptr.hpp 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #ifndef BOOST_SERIALIZATION_SCOPED_PTR_HPP_VP_2003_10_30
  2. #define BOOST_SERIALIZATION_SCOPED_PTR_HPP_VP_2003_10_30
  3. #if defined(_MSC_VER)
  4. # pragma once
  5. #endif
  6. // Copyright (c) 2003 Vladimir Prus.
  7. // Use, modification and distribution is subject to the Boost Software
  8. // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  9. // http://www.boost.org/LICENSE_1_0.txt)
  10. // Provides non-intrusive serialization for boost::scoped_ptr
  11. // Does not allow to serialize scoped_ptr's to builtin types.
  12. #include <boost/config.hpp>
  13. #include <boost/scoped_ptr.hpp>
  14. #include <boost/serialization/nvp.hpp>
  15. #include <boost/serialization/split_free.hpp>
  16. namespace boost {
  17. namespace serialization {
  18. template<class Archive, class T>
  19. void save(
  20. Archive & ar,
  21. const boost::scoped_ptr< T > & t,
  22. const unsigned int /* version */
  23. ){
  24. T* r = t.get();
  25. ar << boost::serialization::make_nvp("scoped_ptr", r);
  26. }
  27. template<class Archive, class T>
  28. void load(
  29. Archive & ar,
  30. boost::scoped_ptr< T > & t,
  31. const unsigned int /* version */
  32. ){
  33. T* r;
  34. ar >> boost::serialization::make_nvp("scoped_ptr", r);
  35. t.reset(r);
  36. }
  37. template<class Archive, class T>
  38. void serialize(
  39. Archive& ar,
  40. boost::scoped_ptr< T >& t,
  41. const unsigned int version
  42. ){
  43. boost::serialization::split_free(ar, t, version);
  44. }
  45. } // namespace serialization
  46. } // namespace boost
  47. #endif // BOOST_SERIALIZATION_SCOPED_PTR_HPP_VP_2003_10_30