Serializing Boost.Tuple

Hi,
Just thought I would share some code that serializes Boost.Tuple using
Boost.Serialization:
#include

Is there any plan to include this code to a tuple header?
tuple_serialization.hpp ?
On Wed, Mar 5, 2008 at 2:57 PM, Sohail Somani
Hi,
Just thought I would share some code that serializes Boost.Tuple using Boost.Serialization:
#include
#include #include namespace boost { namespace serialization {
#define GENERATE_ELEMENT_SERIALIZE(z,which,unused) \ ar & boost::serialization::make_nvp("element",t.get< which >());
#define GENERATE_TUPLE_SERIALIZE(z,nargs,unused) \ template< typename Archive, BOOST_PP_ENUM_PARAMS(nargs,typename T) > \ void serialize(Archive & ar, \ boost::tuple< BOOST_PP_ENUM_PARAMS(nargs,T) > & t, \ const unsigned int version) \ { \ BOOST_PP_REPEAT_FROM_TO(0,nargs,GENERATE_ELEMENT_SERIALIZE,~) \ }
BOOST_PP_REPEAT_FROM_TO(1,10,GENERATE_TUPLE_SERIALIZE,~);
}}
It does not handle 0-element tuples (not sure that it should, actually!) Kudos to the insanity that produced Boost.Preprocessor.
-- Sohail Somani http://uint32t.blogspot.com
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
-- Felipe Magno de Almeida

On Thu, 27 Mar 2008 15:27:46 -0300, Felipe Magno de Almeida wrote:
Is there any plan to include this code to a tuple header? tuple_serialization.hpp ?
I think the best way to get it looked at would be to file a bug.
Anyway, if there was an is_tuple<T> metafunction, there would be a more
elegant way to do it:
// not compiled or tested
namespace boost { namespace serialization {
template

On Thu, 27 Mar 2008 19:00:34 +0000, Sohail Somani wrote:
On Thu, 27 Mar 2008 15:27:46 -0300, Felipe Magno de Almeida wrote:
Is there any plan to include this code to a tuple header? tuple_serialization.hpp ?
I think the best way to get it looked at would be to file a bug.
Anyway, if there was an is_tuple<T> metafunction, there would be a more elegant way to do it:
Hmm, no I lied. You couldn't do it this way because then the overload would be ambiguous when it matched. I think... -- Sohail Somani http://uint32t.blogspot.com

On Thu, Mar 27, 2008 at 4:23 PM, Sohail Somani
On Thu, 27 Mar 2008 19:00:34 +0000, Sohail Somani wrote:
[snip]
Anyway, if there was an is_tuple<T> metafunction, there would be a more elegant way to do it:
Hmm, no I lied. You couldn't do it this way because then the overload would be ambiguous when it matched. I think...
Ambigous with what?
-- Sohail Somani http://uint32t.blogspot.com
-- Felipe Magno de Almeida

On Thu, Mar 27, 2008 at 4:32 PM, Felipe Magno de Almeida
[snip]
Hmm, no I lied. You couldn't do it this way because then the overload would be ambiguous when it matched. I think...
Ambigous with what?
I see. With the free serialize function in boost::serialization namespace.
--
Sohail Somani http://uint32t.blogspot.com
-- Felipe Magno de Almeida

On Thu, 27 Mar 2008 16:32:25 -0300, Felipe Magno de Almeida wrote:
Anyway, if there was an is_tuple<T> metafunction, there would be a more elegant way to do it:
Hmm, no I lied. You couldn't do it this way because then the overload would be ambiguous when it matched. I think...
Ambigous with what?
Ambiguous with the other boost::serialization::serialize function. I was
thinking of:
template
participants (2)
-
Felipe Magno de Almeida
-
Sohail Somani