名前空間
変種
操作

std::as_bytes, std::as_writable_bytes

提供: cppreference.com
< cpp‎ | container‎ | span
template< class T, std::size_t N>
std::span<const std::byte, S/* see below */> as_bytes(std::span<T, N> s) noexcept;
(1)
template< class T, std::size_t N>
std::span<std::byte, S/* see below */> as_writable_bytes(std::span<T, N> s) noexcept;
(2)

スパン s の要素のオブジェクト表現に対するビューを取得します。

Nstd::dynamic_extent の場合、返されるスパンのエクステント Sstd::dynamic_extent です。 そうでなければ、 Ssizeof(T) * N です。

as_writable_bytes は、 std::is_const_v<T>false の場合にのみ、オーバーロード解決に参加します。

[編集] 戻り値

1) {reinterpret_cast<const std::byte*>(s.data()), s.size_bytes()} で構築されたスパン。
2) {reinterpret_cast<std::byte*>(s.data()), s.size_bytes()} で構築されたスパン。