"niranjan bangera" <niranjannina@gmail.com> wrote in message news:50a2f6f20902172223s69f3d39ft2b337c0c3ec6dbbc@mail.gmail.com...Hi all,
I want to clarify myself in serialization of union and array, Please clarify my doubts.
Boost Version:1.36.0
Compiler :/_TOOLS_/dist/gnu-gcc-/4.1.1-binutils-2.16.1/x86_64-pc-linux2.4/bin/gcc
class A {
union my_union {
uint64_t array1[ 4];
int64_t array2[4];
double dbl [4];
uint32_t array3 [ 8 ];
int32_t array4 [ 8 ];
float flt [ 8];
uint16_t array5[ 16 ];
int16_t array6[ 16 ];
uint8_t array7 [ 32 ];
int8_t arrray8[ 32 ];
}
my_union my_obj;
friend class boost::serialization::access;
template<class Archive>
void serialize(Archive & ar, const unsigned int file_version)
{
ar & my_obj.array1;
}
};
Is it safe to do it, or any othe optimised method is there to do it?This should work if my_union in fact contains array1[4]. But what happens if it contains something else.Look into variant which is typesafe AND already serializable.
how to serialize a dynamicaly allocated array
struc my_struct{
int x;
}
struct new_struct {
{
my_struct **my_var; ///my_struct is a structure defined before this structure.
}
Currently, pointers to pointers cannot be serialized. This is the subject of a TRAK item.
In this case do i need to serialize each element int the array manually, Pointed By my_varConsider using a pointer to an std::vector. Serialization is free for this case.
Is there other some other way to do it...
Thanks,
Niranjan
Robert Ramey
_______________________________________________
Boost-users mailing list
Boost-users@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users