Skip to content

Latest commit

 

History

History
65 lines (47 loc) · 1.04 KB

File metadata and controls

65 lines (47 loc) · 1.04 KB

size_bytes

  • span[meta header]
  • std[meta namespace]
  • span[meta class]
  • function[meta id-type]
  • cpp20[meta cpp]
constexpr size_type size_bytes() const noexcept;

概要

参照している範囲のバイト数を取得する。

戻り値

以下と等価:

return size() * sizeof(element_type);
  • size()[link size.md]

例外

投げない

計算量

定数時間

#include <cassert>
#include <span>
#include <vector>

int main()
{
  std::vector<int> v = {1, 2, 3, 4, 5};

  assert(std::span{v}.size_bytes() == 5 * sizeof(int));
  assert(std::span{v}.first(3).size_bytes() == 3 * sizeof(int));
}
  • size_bytes()[color ff0000]
  • first[link first.md]

出力

バージョン

言語

  • C++20

処理系

参照