Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2024-11-15 09:31:00

0001 #ifndef  BOOST_SERIALIZATION_COMPLEX_HPP
0002 #define BOOST_SERIALIZATION_COMPLEX_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 // serialization/utility.hpp:
0011 // serialization for stl utility templates
0012 
0013 // (C) Copyright 2007 Matthias Troyer .
0014 // Use, modification and distribution is subject to the Boost Software
0015 // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
0016 // http://www.boost.org/LICENSE_1_0.txt)
0017 
0018 //  See http://www.boost.org for updates, documentation, and revision history.
0019 
0020 #include <complex>
0021 #include <boost/config.hpp>
0022 
0023 #include <boost/serialization/nvp.hpp>
0024 #include <boost/serialization/is_bitwise_serializable.hpp>
0025 #include <boost/serialization/split_free.hpp>
0026 
0027 namespace boost {
0028 namespace serialization {
0029 
0030 template<class Archive, class T>
0031 inline void serialize(
0032     Archive & ar,
0033     std::complex< T > & t,
0034     const unsigned int file_version
0035 ){
0036     boost::serialization::split_free(ar, t, file_version);
0037 }
0038 
0039 template<class Archive, class T>
0040 inline void save(
0041     Archive & ar,
0042     std::complex< T > const & t,
0043     const unsigned int /* file_version */
0044 ){
0045     const T re = t.real();
0046     const T im = t.imag();
0047     ar << boost::serialization::make_nvp("real", re);
0048     ar << boost::serialization::make_nvp("imag", im);
0049 }
0050 
0051 template<class Archive, class T>
0052 inline void load(
0053     Archive & ar,
0054     std::complex< T >& t,
0055     const unsigned int /* file_version */
0056 ){
0057     T re;
0058     T im;
0059     ar >> boost::serialization::make_nvp("real", re);
0060     ar >> boost::serialization::make_nvp("imag", im);
0061     t = std::complex< T >(re,im);
0062 }
0063 
0064 // specialization of serialization traits for complex
0065 template <class T>
0066 struct is_bitwise_serializable<std::complex< T > >
0067     : public is_bitwise_serializable< T > {};
0068 
0069 template <class T>
0070 struct implementation_level<std::complex< T > >
0071     : mpl::int_<object_serializable> {} ;
0072 
0073 // treat complex just like builtin arithmetic types for tracking
0074 template <class T>
0075 struct tracking_level<std::complex< T > >
0076     : mpl::int_<track_never> {} ;
0077 
0078 } // serialization
0079 } // namespace boost
0080 
0081 #endif // BOOST_SERIALIZATION_COMPLEX_HPP