is it safe to memcopy myvect.size()*sizeof(foo) bytes from the memoryadress of the first element of a
std::vector<std::pair<T1, T2> > myvect
into an array of
struct foo{
T1 first;
T2 second;
}
if the array is allocated with the same number of elements as the vector’s size?
thanks
No, a class containing
T1andT2is not guaranteed the same layout or alignment asstd::pair<T1, T2>, at least in C++98 (sincestd::pairis not a POD type). The story may be different in C++0x.