- span[meta header]
- std[meta namespace]
- span[meta class]
- function[meta id-type]
- cpp20[meta cpp]
constexpr index_type size() const noexcept;
参照している要素数を取得する。
メンバ変数として保持している要素数を返す。
投げない
定数時間
#include <cassert>
#include <span>
#include <vector>
int main()
{
std::vector<int> v = {1, 2, 3, 4, 5};
assert(std::span{v}.size() == 5);
assert(std::span{v}.first(3).size() == 3);
}
- size()[color ff0000]
- first[link first.md]
- C++20
- Clang: 9.0
- GCC: ??
- Visual C++: ??