|
Boost-Commit : |
From: troyer_at_[hidden]
Date: 2008-06-15 13:46:19
Author: troyer
Date: 2008-06-15 13:46:18 EDT (Sun, 15 Jun 2008)
New Revision: 46411
URL: http://svn.boost.org/trac/boost/changeset/46411
Log:
Added serialization support for boost::array
Text files modified:
trunk/boost/archive/detail/iserializer.hpp | 1 +
trunk/boost/serialization/array.hpp | 14 +++++++++++---
trunk/boost/serialization/utility.hpp | 4 ----
trunk/libs/serialization/test/test_array.cpp | 6 ++++++
4 files changed, 18 insertions(+), 7 deletions(-)
Modified: trunk/boost/archive/detail/iserializer.hpp
==============================================================================
--- trunk/boost/archive/detail/iserializer.hpp (original)
+++ trunk/boost/archive/detail/iserializer.hpp 2008-06-15 13:46:18 EDT (Sun, 15 Jun 2008)
@@ -67,6 +67,7 @@
#include <boost/archive/detail/basic_iarchive.hpp>
#include <boost/archive/detail/basic_iserializer.hpp>
#include <boost/archive/detail/archive_pointer_iserializer.hpp>
+#include <boost/archive/archive_exception.hpp>
#include <boost/serialization/serialization.hpp>
#include <boost/serialization/version.hpp>
Modified: trunk/boost/serialization/array.hpp
==============================================================================
--- trunk/boost/serialization/array.hpp (original)
+++ trunk/boost/serialization/array.hpp 2008-06-15 13:46:18 EDT (Sun, 15 Jun 2008)
@@ -9,13 +9,11 @@
#include <boost/serialization/nvp.hpp>
#include <boost/serialization/split_member.hpp>
#include <boost/serialization/wrapper.hpp>
-#include <boost/serialization/collection_size_type.hpp>
-#include <boost/archive/archive_exception.hpp>
-#include <boost/throw_exception.hpp>
#include <boost/mpl/always.hpp>
#include <boost/mpl/apply.hpp>
#include <boost/mpl/bool.hpp>
#include <boost/type_traits/remove_const.hpp>
+#include <boost/array.hpp>
#include <iostream>
namespace boost { namespace serialization {
@@ -106,6 +104,16 @@
return array<T>(t, s);
}
+
+template <class Archive, class T, std::size_t N>
+
+void serialize(Archive& ar, boost::array<T,N>& a, const unsigned int version)
+{
+ ar & make_nvp("elems",a.elems);
+}
+
+
+
} } // end namespace boost::serialization
Modified: trunk/boost/serialization/utility.hpp
==============================================================================
--- trunk/boost/serialization/utility.hpp (original)
+++ trunk/boost/serialization/utility.hpp 2008-06-15 13:46:18 EDT (Sun, 15 Jun 2008)
@@ -50,10 +50,6 @@
{
};
-//template <class T, class U>
-//struct implementation_level<std::pair<T,U> >
-// : mpl::int_<object_serializable> {} ;
-
} // serialization
} // namespace boost
Modified: trunk/libs/serialization/test/test_array.cpp
==============================================================================
--- trunk/libs/serialization/test/test_array.cpp (original)
+++ trunk/libs/serialization/test/test_array.cpp 2008-06-15 13:46:18 EDT (Sun, 15 Jun 2008)
@@ -20,6 +20,7 @@
#include "test_tools.hpp"
#include <boost/detail/no_exceptions_support.hpp>
#include <boost/archive/archive_exception.hpp>
+#include <boost/array.hpp>
#include "A.hpp"
#include "A.ipp"
@@ -58,24 +59,29 @@
// test array of objects
const T a_array[10]={T(),T(),T(),T(),T(),T(),T(),T(),T(),T()};
const T b_array[2][3]={{T(),T(),T()},{T(),T(),T()}};
+ const boost::array<T,10> c_array = boost::array<T,10>();
{
test_ostream os(testfile, TEST_STREAM_FLAGS);
test_oarchive oa(os, TEST_ARCHIVE_FLAGS);
oa << boost::serialization::make_nvp("a_array", a_array);
oa << boost::serialization::make_nvp("b_array", b_array);
+ oa << boost::serialization::make_nvp("c_array", c_array);
}
{
T a_array1[10];
T b_array1[2][3];
+ boost::array<T,10> c_array1;
test_istream is(testfile, TEST_STREAM_FLAGS);
test_iarchive ia(is, TEST_ARCHIVE_FLAGS);
ia >> boost::serialization::make_nvp("a_array", a_array1);
ia >> boost::serialization::make_nvp("b_array", b_array1);
+ ia >> boost::serialization::make_nvp("c_array", c_array1);
array_equal_to/*<A[10]>*/ Compare;
BOOST_CHECK(Compare(a_array, a_array1));
BOOST_CHECK(Compare(b_array[0], b_array1[0]));
BOOST_CHECK(Compare(b_array[1], b_array1[1]));
+ BOOST_CHECK(Compare(c_array, c_array1));
}
{
T a_array1[9];
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