简体   繁体   中英

what does “layout-compatible with C” mean?

It is said that stl vector is "layout-compatible with C". Where can I find the definition of "layout-compatible with C"?

这意味着,只要向量不为空, &vector.front()将为您提供指向连续对象数组的指针,这些对象可以传递给期望此类数组的C API。

It means that the contents of the vector will be laid out in memory the same way they would be in a C array of the same type. That means that if you have a C function that expects to receive a pointer to an array of some type, you can use a vector and pass the function a pointer to the first element of the vector.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM