Boost logo

Boost-Commit :

From: troyer_at_[hidden]
Date: 2007-11-19 07:15:58


Author: troyer
Date: 2007-11-19 07:15:58 EST (Mon, 19 Nov 2007)
New Revision: 41221
URL: http://svn.boost.org/trac/boost/changeset/41221

Log:
made complex seriaqlization more portable
Text files modified:
   trunk/boost/serialization/complex.hpp | 36 ++++++++++++++++++++++++++++++++----
   1 files changed, 32 insertions(+), 4 deletions(-)

Modified: trunk/boost/serialization/complex.hpp
==============================================================================
--- trunk/boost/serialization/complex.hpp (original)
+++ trunk/boost/serialization/complex.hpp 2007-11-19 07:15:58 EST (Mon, 19 Nov 2007)
@@ -26,14 +26,42 @@
 namespace boost {
 namespace serialization {
 
+
 template<class Archive, class T>
 inline void serialize(
     Archive & ar,
- std::complex<T> & x,
+ std::complex<T> & t,
+ const unsigned int file_version
+)
+{
+ boost::serialization::split_free(ar, t, file_version);
+}
+
+template<class Archive, class T>
+inline void save(
+ Archive & ar,
+ std::complex<T> const& x,
     const unsigned int /* file_version */
-){
- ar & boost::serialization::make_nvp("real", x.real());
- ar & boost::serialization::make_nvp("imag", x.imag());
+)
+{
+ double re=x.real();
+ double im=x.imag();
+ ar << boost::serialization::make_nvp("real", re);
+ ar << boost::serialization::make_nvp("imag", im);
+}
+
+template<class Archive, class T>
+inline void load(
+ Archive & ar,
+ std::complex<T>& x,
+ const unsigned int /* file_version */
+)
+{
+ double re;
+ double im;
+ ar >> boost::serialization::make_nvp("real", re);
+ ar >> boost::serialization::make_nvp("imag", im);
+ x = std::complex<T>(re,im);
 }
 
 /// specialization of serialization traits for complex


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk