Boost logo

Boost Users :

From: Felipe Magno de Almeida (felipe.m.almeida_at_[hidden])
Date: 2008-03-27 14:27:46


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 <sohail_at_[hidden]> wrote:
> Hi,
>
> Just thought I would share some code that serializes Boost.Tuple using
> Boost.Serialization:
>
> #include <boost/tuple/tuple.hpp>
> #include <boost/serialization/nvp.hpp>
> #include <boost/preprocessor/repetition.hpp>
>
> 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_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>

-- 
Felipe Magno de Almeida

Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net