Boost logo

Boost Users :

Subject: Re: [Boost-users] [serialization][1.49]How to serializeshared_ptr<void>?
From: harr999y (79481268_at_[hidden])
Date: 2012-05-19 19:00:07


Robert Ramey wrote
>
> You really need to think about what void * means in your program.
> Usually it's just a place holder for any kind of pointer. Maybe
> you want to consider using boost::any instead of void *, (I don't
> know if serialization has been implemented for boost::any) or
> perhaps boost::variant which DOES have serialization implemented.
>
> Robert Ramey
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_.boost
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>
Hi,Robert Ramey.I come back,when I discover about the boost::variant,I find
it cannot satisfy my request.
And finally I use vector to solve it,with the thinking that vector can store
memory.Cheers!

That's what I want to share,and maybe it's helpful to someone who want to
store a sequence raw data with serialization.

I create a vector like:

Engine::Uint8Vector dataVec((sizeof(type) /
sizeof(Engine::Uint8Vector::value_type)) * indexCount);

and then when I need the data to read or modify,just :

type * data = reinterpret_cast<type *>(dataVec.data());
p.s:Sorry for using reinterpret_cast,but I cannot have a better idea here.

It solved what I need.Maybe it's a so simple method,but it's useful. :)

Thanks again for this great lib.

Harry

--
View this message in context: http://boost.2283326.n4.nabble.com/serialization-1-49-How-to-serialize-shared-ptr-void-tp4630232p4630239.html
Sent from the Boost - Users mailing list archive at Nabble.com.

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