40 lines
1.2 KiB
Markdown
40 lines
1.2 KiB
Markdown
[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.7 Arithmetic 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.1 General"))[.](#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)
|