tuple memory alignment

Hi! I'm currently playing around with boost::tuple and std::vector. I noticed that having a std::vector containing boost::tuple elements has "dense" memory layout. My question: is this intended behavior, or will it go away in the future? (The current state is much to my advantage: instead of allocating memory C style and copying lots of data in order to feed some C API, I can reinterpret_cast a pointer, and everything is fine.) Thanks Sebastian

On Thursday 15 October 2009 14:53:04 Sebastian Hegler wrote:
I noticed that having a std::vector containing boost::tuple elements has "dense" memory layout.
std::vector is guaranteed to layout data as a contiguous array of its elements, i.e., for a vector v of size k (parantheses added for clarity), ( &( v[0] ) )[m] points to v[m] for m less than k. I don't know a tuple could guarantee that its elements are stored in same way as a C struct. Regards, Ravi
participants (2)
-
Ravi
-
Sebastian Hegler