Well, if you need the exact number of bytes, you will need to take into account the size of std::vector objects I think :).
On Sun, Jun 9, 2013 at 10:07 AM, Stephan Woermann < [email protected]> wrote: > To get the total size of the struct, this should work: > > Foo test; > sizeof( double ) * test.A.size() + sizeof( double ) * test.B.size() + > sizeof( bool ) * 2 > > Stephan > > > 2013/6/9 Guillaume Laforge <[email protected]> > >> Hi Ahmidou :), >> >> You could try to use pointers to std::vector. This way you will be able >> to access those vector and get the double values correctly. >> But you must handle the allocation/deallocation of those vectors by >> yourself: >> >> struct Foo{ >> std::vector<double> *A; >> std::vector<double> *B; >> bool C; >> bool D; >> >> Foo() >> { >> A = new std::vector<double>; >> B = new std::vector<double>; >> } >> ~Foo() >> { >> delete A; >> delete B; >> } >> }; >> >> Hope this help, >> >> Guillaume >> >> >> On Sun, Jun 9, 2013 at 8:07 AM, Ahmidou Lyazidi <[email protected]>wrote: >> >>> Hi List, >>> Is it possible to store this kind of struct in a UserData (map or blob): >>> >>> struct Foo{ >>> std::vector<double> A; >>> std::vector<double> B; >>> bool C; >>> bool D; >>> }; >>> >>> I can pull out the structure, and the vectors have the good number of >>> item...but they are empty, the values are gone >>> >>> I'm not sure, but I think it's lost because of the size parameter in >>> UserDataMap.PutItemValue >>> I tried to set the real size ( sizeof(vector)+ sizeof(double)*vector::size() >>> ) but this gave me some crazy results. >>> >>> Any idea? >>> >>> Thanks >>> >>> ----------------------------------------------- >>> Ahmidou Lyazidi >>> Director | TD | CG artist >>> http://vimeo.com/ahmidou/videos >>> http://www.cappuccino-films.com >>> >> >> >

