Files
cppdraft_translate/cppdraft/span/objectrep.md
2025-10-25 03:02:53 +03:00

42 lines
1.4 KiB
Markdown

[span.objectrep]
# 23 Containers library [[containers]](./#containers)
## 23.7 Views [[views]](views#span.objectrep)
### 23.7.2 Contiguous access [[views.contiguous]](views.contiguous#span.objectrep)
#### 23.7.2.3 Views of object representation [span.objectrep]
[🔗](#lib:as_bytes)
`template<class ElementType, size_t Extent>
span<const byte, Extent == dynamic_extent ? dynamic_extent : sizeof(ElementType) * Extent>
as_bytes(span<ElementType, Extent> s) noexcept;
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L20965)
*Effects*: Equivalent to: return R{reinterpret_cast<const byte*>(s.data()), s.size_bytes()}; where R is the return type[.](#1.sentence-1)
[🔗](#lib:as_writable_bytes)
`template<class ElementType, size_t Extent>
span<byte, Extent == dynamic_extent ? dynamic_extent : sizeof(ElementType) * Extent>
as_writable_bytes(span<ElementType, Extent> s) noexcept;
`
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L20979)
*Constraints*: is_const_v<ElementType> is false[.](#2.sentence-1)
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L20983)
*Effects*: Equivalent to: return R{reinterpret_cast<byte*>(s.data()), s.size_bytes()}; where R is the return type[.](#3.sentence-1)