简体   繁体   中英

How to get std::deque pointer to the raw data?

I know for std::vector, std::vector: data() and &something[0] are both OK, what about std::deque? There is no data() function for std::deque.

Edit: if std::deque is not guaranteed to use contiguous storage, how do i implement a deque that can get the raw data ?

The data contained in deque is not guaranteed to be placed in continuous memory block. This means that there could not be function similar to data() of vector.

No, the double-ended queue is a dynamically growing data structure. Unlike the std::vector it is not layed-out in memory like an array but as arbitrary memory locations pointing to the previous and to the next memory section.

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