C++20 includes std::span
, which "describes an object that can refer to a contiguous sequence of objects with the first element of the sequence at position zero". Its interface is very close to std::array
, though it supports dynamic extent as well as fixed one.
The obvious difference is that std::array
owns its elements (and so its destructor destroys them) and std::span
doesn't.
Is there anything else array
can be used for that span
can't?