Is it safe to get address of first element in std::vector
and use it like raw array? Is data aligned continously? What c++ standard says (c++98
vs c++11
)? Is it a common practice by the way?
I have some array which size may vary and function which takes pointer and number of elements as argument. It would be great to manage data with std::vector
and use it with my_func
at same time.
std::vector<int> my_vector;
void my_func(int* int_ptr, int num_ints);
// ..
my_func(&my_vector[0], my_vector.size());