123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899 |
- #ifndef BOOST_SERIALIZATION_WEAK_PTR_HPP
- #define BOOST_SERIALIZATION_WEAK_PTR_HPP
- #if defined(_MSC_VER)
- # pragma once
- #endif
- #include <boost/weak_ptr.hpp>
- #include <boost/serialization/shared_ptr.hpp>
- namespace boost {
- namespace serialization{
- template<class Archive, class T>
- inline void save(
- Archive & ar,
- const boost::weak_ptr< T > &t,
- const unsigned int /* file_version */
- ){
- const boost::shared_ptr< T > sp = t.lock();
- ar << boost::serialization::make_nvp("weak_ptr", sp);
- }
- template<class Archive, class T>
- inline void load(
- Archive & ar,
- boost::weak_ptr< T > &t,
- const unsigned int /* file_version */
- ){
- boost::shared_ptr< T > sp;
- ar >> boost::serialization::make_nvp("weak_ptr", sp);
- t = sp;
- }
- template<class Archive, class T>
- inline void serialize(
- Archive & ar,
- boost::weak_ptr< T > &t,
- const unsigned int file_version
- ){
- boost::serialization::split_free(ar, t, file_version);
- }
- }
- }
- #ifndef BOOST_NO_CXX11_SMART_PTR
- #include <memory>
- namespace boost {
- namespace serialization{
- template<class Archive, class T>
- inline void save(
- Archive & ar,
- const std::weak_ptr< T > &t,
- const unsigned int /* file_version */
- ){
- const std::shared_ptr< T > sp = t.lock();
- ar << boost::serialization::make_nvp("weak_ptr", sp);
- }
- template<class Archive, class T>
- inline void load(
- Archive & ar,
- std::weak_ptr< T > &t,
- const unsigned int /* file_version */
- ){
- std::shared_ptr< T > sp;
- ar >> boost::serialization::make_nvp("weak_ptr", sp);
- t = sp;
- }
- template<class Archive, class T>
- inline void serialize(
- Archive & ar,
- std::weak_ptr< T > &t,
- const unsigned int file_version
- ){
- boost::serialization::split_free(ar, t, file_version);
- }
- }
- }
- #endif
- #endif
|