|
Boost : |
From: Sebastian Ramacher (s.ramacher_at_[hidden])
Date: 2007-05-28 10:47:49
As of version 1.34, Boost.PtrContainer supports serialization as defined
by Boost.Serialization. Now I'd like to propose a switch to disable this
feature. The attached patch adds checks if
BOOST_PTR_CONTAINER_NO_SERIALZATION is defined around the serialization
related code blocks and enables/disables serialization support.
It's not that I don't like serialization support but on a Debian system
you have to install libboost-serialization-dev and
libboost-serialization1.34.0 just to use Boost.PtrContainer.
The patch was created against CVS HEAD but I'd gladly provide a patch
against 1.34 if it finds any interest.
Regards,
Sebastian
Index: ptr_array.hpp
===================================================================
RCS file: /cvsroot/boost/boost/boost/ptr_container/ptr_array.hpp,v
retrieving revision 1.9
diff -u -r1.9 ptr_array.hpp
--- ptr_array.hpp 16 Feb 2006 23:38:36 -0000 1.9
+++ ptr_array.hpp 28 May 2007 13:35:29 -0000
@@ -190,6 +190,7 @@
return this->c_private()[idx] == 0;
}
+#ifndef BOOST_PTR_CONTAINER_NO_SERIALIZATION
public: // serialization
template< class Archive >
@@ -214,7 +215,7 @@
}
BOOST_SERIALIZATION_SPLIT_MEMBER()
-
+#endif
};
//////////////////////////////////////////////////////////////////////////////
Index: ptr_map_adapter.hpp
===================================================================
RCS file: /cvsroot/boost/boost/boost/ptr_container/ptr_map_adapter.hpp,v
retrieving revision 1.26
diff -u -r1.26 ptr_map_adapter.hpp
--- ptr_map_adapter.hpp 8 Mar 2006 23:16:00 -0000 1.26
+++ ptr_map_adapter.hpp 28 May 2007 13:36:09 -0000
@@ -291,6 +291,7 @@
return replace( where, x.release() );
}
+#ifndef BOOST_PTR_CONTAINER_NO_SERIALIZATION
public: // serialization
template< class Archive >
@@ -305,6 +306,7 @@
ar & ptr_container_detail::serialize_as_const( i->second );
}
}
+#endif
};
} // ptr_container_detail
@@ -472,6 +474,7 @@
return transfer( from.begin(), from.end(), from );
}
+#ifndef BOOST_PTR_CONTAINER_NO_SERIALIZATION
public: // serialization
template< class Archive >
@@ -493,7 +496,7 @@
}
BOOST_SERIALIZATION_SPLIT_MEMBER()
-
+#endif
};
/////////////////////////////////////////////////////////////////////////
@@ -647,6 +650,7 @@
BOOST_ASSERT( from.empty() );
}
+#ifndef BOOST_PTR_CONTAINER_NO_SERIALIZATION
public: // serialization
template< class Archive >
@@ -668,7 +672,7 @@
}
BOOST_SERIALIZATION_SPLIT_MEMBER()
-
+#endif
};
template< class I, class F, class S >
Index: ptr_vector.hpp
===================================================================
RCS file: /cvsroot/boost/boost/boost/ptr_container/ptr_vector.hpp,v
retrieving revision 1.10
diff -u -r1.10 ptr_vector.hpp
--- ptr_vector.hpp 18 Feb 2006 01:41:14 -0000 1.10
+++ ptr_vector.hpp 28 May 2007 13:35:09 -0000
@@ -53,6 +53,7 @@
this->c_private().reserve( n );
}
+#ifndef BOOST_PTR_CONTAINER_NO_SERIALIZATION
public: // serialization
template< class Archive >
@@ -66,7 +67,7 @@
}
BOOST_SERIALIZATION_SPLIT_MEMBER()
-
+#endif
};
//////////////////////////////////////////////////////////////////////////////
Index: detail/reversible_ptr_container.hpp
===================================================================
RCS file: /cvsroot/boost/boost/boost/ptr_container/detail/reversible_ptr_container.hpp,v
retrieving revision 1.24
diff -u -r1.24 reversible_ptr_container.hpp
--- detail/reversible_ptr_container.hpp 6 Mar 2006 20:09:50 -0000 1.24
+++ detail/reversible_ptr_container.hpp 28 May 2007 13:35:10 -0000
@@ -35,7 +35,11 @@
#include <boost/utility/enable_if.hpp>
#include <boost/type_traits/is_pointer.hpp>
#include <boost/type_traits/is_integral.hpp>
+
+#ifndef BOOST_PTR_CONTAINER_NO_SERIALIZATION
#include <boost/serialization/split_member.hpp>
+#endif
+
#include <algorithm>
#include <exception>
#include <memory>
@@ -46,12 +50,13 @@
namespace ptr_container_detail
{
-
+#ifndef BOOST_PTR_CONTAINER_NO_SERIALIZATION
template< class T >
inline T const& serialize_as_const( T const& r )
{
return r;
}
+#endif
template< class CloneAllocator >
struct clone_deleter
@@ -545,6 +550,7 @@
return replace( idx, x.release() );
}
+#ifndef BOOST_PTR_CONTAINER_NO_SERIALIZATION
//
// serialization
//
@@ -602,7 +608,7 @@
}
BOOST_SERIALIZATION_SPLIT_MEMBER()
-
+#endif
}; // 'reversible_ptr_container'
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk