(C++17) | ||||
| Sequence | ||||
(C++11) | ||||
(C++26) | ||||
(C++26) | ||||
(C++11) | ||||
| Associative | ||||
| Unordered associative | ||||
(C++11) | ||||
(C++11) | ||||
(C++11) | ||||
(C++11) | ||||
| Adaptors | ||||
(C++23) | ||||
(C++23) | ||||
(C++23) | ||||
(C++23) | ||||
| Views | ||||
(C++20) | ||||
(C++23) | ||||
| Tables | ||||
| Iterator invalidation | ||||
| Member function table | ||||
| Non-member function table |
| Member functions | ||||
| Element access | ||||
(C++26) | ||||
| Iterators | ||||
(C++23) | ||||
(C++23) | ||||
(C++23) | ||||
(C++23) | ||||
| Observers | ||||
span::size | ||||
| Subviews | ||||
| Non-member functions | ||||
| Non-member constant | ||||
| Deduction guides |
constexpr size_type size()constnoexcept; | (since C++20) | |
Returns the number of elements in the span.
Contents |
The number of elements in the span.
| Feature-test macro | Value | Std | Feature |
|---|---|---|---|
__cpp_lib_ssize | 201902L | (C++20) | std::ssize and unsignedstd::span::size |
#include <span> int main(){constexprstaticint c_array[]{1,2,3,4,5,6,7,8}; constexprstd::span<constint> span{c_array}; static_assert(8== span.size()); static_assert(7== span.first(7).size()); static_assert(6== span.first<6>().size()); static_assert(5== span.last(5).size()); static_assert(4== span.last<4>().size()); static_assert(3== span.subspan(2,3).size()); static_assert(2== span.subspan<3,2>().size()); static_assert(1== span.subspan<7>().size());}
constructs aspan(public member function)[edit] | |
| returns the size of the sequence in bytes (public member function)[edit] |