std::span<T,Extent>:: size
From cppreference.net
|
constexpr
size_type size
(
)
const
noexcept
;
|
(seit C++20) | |
Gibt die Anzahl der Elemente in der Spanne zurück.
Inhaltsverzeichnis |
Rückgabewert
Die Anzahl der Elemente in der Spanne.
Hinweis
| Feature-Test Makro | Wert | Std | Funktion |
|---|---|---|---|
__cpp_lib_ssize
|
201902L
|
(C++20) |
std::ssize
und vorzeichenloser
std::span::size
|
Beispiel
Diesen Code ausführen
#include <span> int main() { constexpr static int c_array[]{1, 2, 3, 4, 5, 6, 7, 8}; constexpr std::span<const int> 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()); }
Siehe auch
konstruiert einen
span
(öffentliche Elementfunktion) |
|
|
gibt die Größe der Sequenz in Bytes zurück
(öffentliche Elementfunktion) |