Jump to content

C++: Difference between revisions

553 bytes added ,  20 October 2023
Line 510: Line 510:
my_vec.back();
my_vec.back();
</syntaxhighlight>
</syntaxhighlight>
====std::span====
<code>#include &lt;span&gt;</code><br>
https://en.cppreference.com/w/cpp/container/span<br>
This is view of some contiguous amount of memory. If the size is static, this is equivalent to a single pointer, otherwise is it equivalent to two pointers (i.e. begin and end).
If you use this as the parameter to your function, it will accept both arrays and vectors.
Additionaly, there is a [https://en.cppreference.com/w/cpp/container/span/subspan subspan] function so you don't need to pass around indices or pointers to get subvectors.


====std::deque====
====std::deque====