名前空間
変種
操作

std::span<T,Extent>::size_bytes

From cppreference.com
< cpp‎ | container‎ | span
 
 
 
 
constexpr size_type size_bytes() const noexcept;
(C++20以降)

シーケンスのバイト単位のサイズを返します。

目次

[編集] パラメータ

(なし)

[編集] 戻り値

シーケンスのバイト単位のサイズ、すなわち size() * sizeof(element_type)

[編集]

#include <cstdint>
#include <span>
 
int main()
{
    constexpr static std::int32_t a[]{1, 2, 3, 4, 5};
    constexpr static std::span s{a};
 
    static_assert
    (
        sizeof(int32_t) == 4 &&
        std::size(a) == 5 &&
        sizeof a == 20 &&
        s.size() == 5 &&
        s.size_bytes() == 20
    );
}

[編集] 関連項目

(C++20)
シーケンス内の要素数を返します
(public member function) [編集]
English 日本語 中文(简体) 中文(繁體)