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

40 lines
1.2 KiB
Markdown
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

[bit.byteswap]
# 22 General utilities library [[utilities]](./#utilities)
## 22.11 Bit manipulation [[bit]](bit#byteswap)
### 22.11.4 byteswap [bit.byteswap]
[🔗](#lib:byteswap)
`template<class T>
constexpr T byteswap(T value) noexcept;
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L15760)
*Constraints*: T models [integral](concepts.arithmetic#concept:integral "18.4.7Arithmetic concepts[concepts.arithmetic]")[.](#1.sentence-1)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L15764)
*Mandates*: T does not have padding bits ([[basic.types.general]](basic.types.general "6.9.1General"))[.](#2.sentence-1)
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L15768)
Let the sequence R comprise
the bytes of the object representation of value in reverse order[.](#3.sentence-1)
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L15772)
*Returns*: An object v of type T such that each byte in the object representation of v is equal to
the byte in the corresponding position in R[.](#4.sentence-1)