All Contiguous-Container and View Relationships
All Contiguous-Container and View Relationships
A compact scan page for how vector, array, string, string_view, span, and mdspan relate through contiguous storage and borrowing semantics.
All Contiguous-Container and View Relationships
A compact scan page for how vector, array, string, string_view, span, and mdspan relate through contiguous storage and borrowing semantics.
Use reference pages to confirm names, categories, nearby facilities, and the constraints that matter before writing or reviewing code.
std::vectorstd::arraystd::basic_stringstd::spanstd::string_viewstd::mdspanvector, array, or string can expose a contiguous buffer through data()span can borrow contiguous elements from arrays, vectors, and similar storagestring_view borrows character sequences without ownershipmdspan layers multidimensional indexing over existing storage rather than owning it#include <map>
#include <string>
int main() {
std::map<std::string, int> counts{std::pair{"Ada", 1}, std::pair{"Bjarne", 2}};
auto [it, inserted] = counts.insert({"Grace", 3});
return inserted ? it->second : 1;
}