Is there a simple (and quick) serialisation method for simple vectors?

P

Pierre Couderc

I want to serialise quickly a "simple" vector :
(simple is to say with basic types and no pointers)
such as :

class c
{
int i,j;
double z;
}

vector<c> cs;

Is there some simple efficient way such as :
memcpy(mybuff, cs , sizeof(what?))...

I am using SGI stl.

Thank you in advance
Pierre Couderc
 
V

Victor Bazarov

Pierre said:
I want to serialise quickly a "simple" vector :
(simple is to say with basic types and no pointers)
such as :

class c
{
int i,j;
double z;
} ;

vector<c> cs;

Supposedly you included the proper headers...
Is there some simple efficient way such as :
memcpy(mybuff, cs , sizeof(what?))...

I am using SGI stl.

What's "mybuff"?

You should probably do

memcpy(mybuff, &cs[0], cs.size() * sizeof(c));

V
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top