1 #ifndef BOOST_SERIALIZATION_UNIQUE_PTR_HPP
2 #define BOOST_SERIALIZATION_UNIQUE_PTR_HPP
4 // MS compatible compilers support #pragma once
9 /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
12 // (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
13 // Use, modification and distribution is subject to the Boost Software
14 // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
15 // http://www.boost.org/LICENSE_1_0.txt)
17 // See http://www.boost.org for updates, documentation, and revision history.
19 #include <boost/serialization/split_free.hpp>
20 #include <boost/serialization/nvp.hpp>
23 namespace serialization {
25 /////////////////////////////////////////////////////////////
26 // implement serialization for unique_ptr< T >
27 // note: this must be added to the boost namespace in order to
28 // be called by the library
29 template<class Archive, class T>
32 const std::unique_ptr< T > &t,
33 const unsigned int /*file_version*/
35 // only the raw pointer has to be saved
36 // the ref count is rebuilt automatically on load
37 const T * const tx = t.get();
38 ar << BOOST_SERIALIZATION_NVP(tx);
41 template<class Archive, class T>
44 std::unique_ptr< T > &t,
45 const unsigned int /*file_version*/
48 ar >> BOOST_SERIALIZATION_NVP(tx);
49 // note that the reset automagically maintains the reference count
53 // split non-intrusive serialization function member into separate
54 // non intrusive save/load member functions
55 template<class Archive, class T>
56 inline void serialize(
58 std::unique_ptr< T > &t,
59 const unsigned int file_version
61 boost::serialization::split_free(ar, t, file_version);
64 } // namespace serialization
68 #endif // BOOST_SERIALIZATION_UNIQUE_PTR_HPP