|
||||
File indexing completed on 2024-11-15 09:31:02
0001 #ifndef BOOST_SERIALIZATION_UNIQUE_PTR_HPP 0002 #define BOOST_SERIALIZATION_UNIQUE_PTR_HPP 0003 0004 // MS compatible compilers support #pragma once 0005 #if defined(_MSC_VER) 0006 # pragma once 0007 #endif 0008 0009 /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 0010 // unique_ptr.hpp: 0011 0012 // (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . 0013 // Use, modification and distribution is subject to the Boost Software 0014 // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at 0015 // http://www.boost.org/LICENSE_1_0.txt) 0016 0017 // See http://www.boost.org for updates, documentation, and revision history. 0018 #include <memory> 0019 #include <boost/serialization/split_free.hpp> 0020 #include <boost/serialization/nvp.hpp> 0021 0022 namespace boost { 0023 namespace serialization { 0024 0025 ///////////////////////////////////////////////////////////// 0026 // implement serialization for unique_ptr< T > 0027 // note: this must be added to the boost namespace in order to 0028 // be called by the library 0029 template<class Archive, class T> 0030 inline void save( 0031 Archive & ar, 0032 const std::unique_ptr< T > &t, 0033 const unsigned int /*file_version*/ 0034 ){ 0035 // only the raw pointer has to be saved 0036 // the ref count is rebuilt automatically on load 0037 const T * const tx = t.get(); 0038 ar << BOOST_SERIALIZATION_NVP(tx); 0039 } 0040 0041 template<class Archive, class T> 0042 inline void load( 0043 Archive & ar, 0044 std::unique_ptr< T > &t, 0045 const unsigned int /*file_version*/ 0046 ){ 0047 T *tx; 0048 ar >> BOOST_SERIALIZATION_NVP(tx); 0049 // note that the reset automagically maintains the reference count 0050 t.reset(tx); 0051 } 0052 0053 // split non-intrusive serialization function member into separate 0054 // non intrusive save/load member functions 0055 template<class Archive, class T> 0056 inline void serialize( 0057 Archive & ar, 0058 std::unique_ptr< T > &t, 0059 const unsigned int file_version 0060 ){ 0061 boost::serialization::split_free(ar, t, file_version); 0062 } 0063 0064 } // namespace serialization 0065 } // namespace boost 0066 0067 0068 #endif // BOOST_SERIALIZATION_UNIQUE_PTR_HPP
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |