summaryrefslogtreecommitdiff
path: root/boost/serialization/array.hpp
diff options
context:
space:
mode:
authorDongHun Kwak <dh0128.kwak@samsung.com>2016-10-06 10:38:45 +0900
committerDongHun Kwak <dh0128.kwak@samsung.com>2016-10-06 10:39:52 +0900
commit5cde13f21d36c7224b0e13d11c4b49379ae5210d (patch)
treee8269ac85a4b0f7d416e2565fa4f451b5cb41351 /boost/serialization/array.hpp
parentd9ec475d945d3035377a0d89ed42e382d8988891 (diff)
downloadboost-5cde13f21d36c7224b0e13d11c4b49379ae5210d.tar.gz
boost-5cde13f21d36c7224b0e13d11c4b49379ae5210d.tar.bz2
boost-5cde13f21d36c7224b0e13d11c4b49379ae5210d.zip
Imported Upstream version 1.61.0
Change-Id: I96a1f878d1e6164f01e9aadd5147f38fca448d90 Signed-off-by: DongHun Kwak <dh0128.kwak@samsung.com>
Diffstat (limited to 'boost/serialization/array.hpp')
-rw-r--r--boost/serialization/array.hpp90
1 files changed, 54 insertions, 36 deletions
diff --git a/boost/serialization/array.hpp b/boost/serialization/array.hpp
index 97ac0c2501..2cd023aca9 100644
--- a/boost/serialization/array.hpp
+++ b/boost/serialization/array.hpp
@@ -6,13 +6,9 @@
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
-#include <boost/config.hpp> // msvc 6.0 needs this for warning suppression
+//#include <iostream>
-#include <iostream>
-#include <cstddef> // std::size_t
-#ifndef BOOST_NO_CXX11_HDR_ARRAY
-#include <array>
-#endif
+#include <boost/config.hpp> // msvc 6.0 needs this for warning suppression
#if defined(BOOST_NO_STDC_NAMESPACE)
namespace std{
@@ -23,11 +19,13 @@ namespace std{
#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/mpl/always.hpp>
#include <boost/mpl/apply.hpp>
-#include <boost/mpl/bool.hpp>
+#include <boost/mpl/bool_fwd.hpp>
#include <boost/type_traits/remove_const.hpp>
-#include <boost/array.hpp>
+#include <boost/type_traits/is_integral.hpp>
+#include <boost/static_assert.hpp>
namespace boost { namespace serialization {
@@ -37,24 +35,27 @@ template <class Archive>
struct use_array_optimization : boost::mpl::always<boost::mpl::false_> {};
template<class T>
-class array :
- public wrapper_traits<const array< T > >
+class array_wrapper :
+ public wrapper_traits<const array_wrapper< T > >
{
-public:
- typedef T value_type;
-
- array(value_type* t, std::size_t s) :
- m_t(t),
- m_element_count(s)
- {}
- array(const array & rhs) :
+private:
+ array_wrapper & operator=(const array_wrapper & rhs);
+public:
+ // note: I would like to make the copy constructor private but this breaks
+ // make_array. So I try to make make_array a friend - but that doesn't
+ // build. Need a C++ guru to explain this!
+ template<class S>
+ friend const boost::serialization::array_wrapper<T> make_array( T* t, S s);
+
+ array_wrapper(const array_wrapper & rhs) :
m_t(rhs.m_t),
m_element_count(rhs.m_element_count)
{}
- array & operator=(const array & rhs){
- m_t = rhs.m_t;
- m_element_count = rhs.m_element_count;
- }
+public:
+ array_wrapper(T * t, std::size_t s) :
+ m_t(t),
+ m_element_count(s)
+ {}
// default implementation
template<class Archive>
@@ -62,7 +63,7 @@ public:
{
// default implemention does the loop
std::size_t c = count();
- value_type * t = address();
+ T * t = address();
while(0 < c--)
ar & boost::serialization::make_nvp("item", *t++);
}
@@ -99,7 +100,7 @@ public:
serialize_optimized(ar,version,use_optimized());
}
- value_type* address() const
+ T * address() const
{
return m_t;
}
@@ -108,26 +109,32 @@ public:
{
return m_element_count;
}
-
+
private:
- value_type* m_t;
- std::size_t m_element_count;
+ T * const m_t;
+ const std::size_t m_element_count;
};
-template<class T>
+template<class T, class S>
inline
-const array< T > make_array( T* t, std::size_t s){
- return array< T >(t, s);
+const array_wrapper< T > make_array( T* t, S s){
+ const array_wrapper< T > a(t, s);
+ return a;
}
-// implement serialization for boost::array
-template <class Archive, class T, std::size_t N>
-void serialize(Archive& ar, boost::array<T,N>& a, const unsigned int /* version */)
-{
- ar & boost::serialization::make_nvp("elems", a.elems);
-}
+} } // end namespace boost::serialization
+
+// I can't figure out why BOOST_NO_CXX11_HDR_ARRAY
+// has been set for clang-11. So just make sure
+// it's reset now. Needs further research!!!
+
+#if defined(_LIBCPP_VERSION)
+#undef BOOST_NO_CXX11_HDR_ARRAY
+#endif
#ifndef BOOST_NO_CXX11_HDR_ARRAY
+#include <array>
+namespace boost { namespace serialization {
// implement serialization for std::array
template <class Archive, class T, std::size_t N>
void serialize(Archive& ar, std::array<T,N>& a, const unsigned int /* version */)
@@ -138,8 +145,19 @@ void serialize(Archive& ar, std::array<T,N>& a, const unsigned int /* version */
);
}
+} } // end namespace boost::serialization
#endif
+#include <boost/array.hpp>
+
+namespace boost { namespace serialization {
+// implement serialization for boost::array
+template <class Archive, class T, std::size_t N>
+void serialize(Archive& ar, boost::array<T,N>& a, const unsigned int /* version */)
+{
+ ar & boost::serialization::make_nvp("elems", a.elems);
+}
+
} } // end namespace boost::serialization
#define BOOST_SERIALIZATION_USE_ARRAY_OPTIMIZATION(Archive) \