annotate DEPENDENCIES/generic/include/boost/serialization/unique_ptr.hpp @ 125:34e428693f5d vext

Vext -> Repoint
author Chris Cannam
date Thu, 14 Jun 2018 11:15:39 +0100
parents f46d142149f5
children
rev   line source
Chris@102 1 #ifndef BOOST_SERIALIZATION_UNIQUE_PTR_HPP
Chris@102 2 #define BOOST_SERIALIZATION_UNIQUE_PTR_HPP
Chris@102 3
Chris@102 4 // MS compatible compilers support #pragma once
Chris@102 5 #if defined(_MSC_VER)
Chris@102 6 # pragma once
Chris@102 7 #endif
Chris@102 8
Chris@102 9 /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
Chris@102 10 // unique_ptr.hpp:
Chris@102 11
Chris@102 12 // (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
Chris@102 13 // Use, modification and distribution is subject to the Boost Software
Chris@102 14 // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
Chris@102 15 // http://www.boost.org/LICENSE_1_0.txt)
Chris@102 16
Chris@102 17 // See http://www.boost.org for updates, documentation, and revision history.
Chris@102 18 #include <memory>
Chris@102 19 #include <boost/serialization/split_free.hpp>
Chris@102 20 #include <boost/serialization/nvp.hpp>
Chris@102 21
Chris@102 22 namespace boost {
Chris@102 23 namespace serialization {
Chris@102 24
Chris@102 25 /////////////////////////////////////////////////////////////
Chris@102 26 // implement serialization for unique_ptr< T >
Chris@102 27 // note: this must be added to the boost namespace in order to
Chris@102 28 // be called by the library
Chris@102 29 template<class Archive, class T>
Chris@102 30 inline void save(
Chris@102 31 Archive & ar,
Chris@102 32 const std::unique_ptr< T > &t,
Chris@102 33 const unsigned int file_version
Chris@102 34 ){
Chris@102 35 // only the raw pointer has to be saved
Chris@102 36 // the ref count is rebuilt automatically on load
Chris@102 37 const T * const tx = t.get();
Chris@102 38 ar << BOOST_SERIALIZATION_NVP(tx);
Chris@102 39 }
Chris@102 40
Chris@102 41 template<class Archive, class T>
Chris@102 42 inline void load(
Chris@102 43 Archive & ar,
Chris@102 44 std::unique_ptr< T > &t,
Chris@102 45 const unsigned int file_version
Chris@102 46 ){
Chris@102 47 T *tx;
Chris@102 48 ar >> BOOST_SERIALIZATION_NVP(tx);
Chris@102 49 // note that the reset automagically maintains the reference count
Chris@102 50 t.reset(tx);
Chris@102 51 }
Chris@102 52
Chris@102 53 // split non-intrusive serialization function member into separate
Chris@102 54 // non intrusive save/load member functions
Chris@102 55 template<class Archive, class T>
Chris@102 56 inline void serialize(
Chris@102 57 Archive & ar,
Chris@102 58 std::unique_ptr< T > &t,
Chris@102 59 const unsigned int file_version
Chris@102 60 ){
Chris@102 61 boost::serialization::split_free(ar, t, file_version);
Chris@102 62 }
Chris@102 63
Chris@102 64 } // namespace serialization
Chris@102 65 } // namespace boost
Chris@102 66
Chris@102 67
Chris@102 68 #endif // BOOST_SERIALIZATION_UNIQUE_PTR_HPP