c++ - Why isn't a vector of a vector guaranteed to be contiguous? (or is it?) -


i know std::vector elements guaranteed contiguous in memory.

so why can't expect vector containing other vectors have total collection contiguous?

the vector supposed guarantee contiguous memory layout enclosed items, , if enclosures vectors, i'd expect full contents of top-most vector in contiguous memory.

but there seems contention on issue whether or not true. can 1 safely rely on or not? folks seem go out of way achieve this, while i'd think guaranteed.

each of vector inside vector of vectors individual object, , such responsible it's storage. so, no, no means guaranteed contiguous, in fact can 't see situation happen data stored in outer vector , it's inner vectors 1 contiguous block of memory ever.


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -