You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/standard-library/bit-functions.md
+13-11Lines changed: 13 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -23,29 +23,29 @@ The \<bit> header includes the following non-member functions:
23
23
|[countr_one](#countl_one)| Counts the number of consecutive 1 bits, starting from the least significant bit |
24
24
|[popcount](#popcount)| Counts the number of 1 bits in an unsigned integer |
25
25
26
-
## <aname="as_bytes"></a>`as_bytes`
26
+
## <aname="bit_cast"></a>`bit_cast`
27
27
28
-
Get a read-only view of the object representation of the elements in the span.
28
+
Reinterpret `From`.
29
29
30
30
```cpp
31
-
template <classT, size_t Extent>
32
-
auto as_bytes(span<T, Extent> s) noexcept;
31
+
template <classTo, class From>
32
+
To bit_cast(const From& from) noexcept;
33
33
```
34
34
35
35
### Parameters
36
36
37
-
*T*\
38
-
The type of the elements in the span.
37
+
*To*\
38
+
The type of the output.
39
39
40
-
*Extent*\
41
-
The number of elements in the span (if known at compile time), otherwise `dynamic_extent` indicating that the number of elements isn't known until runtime.
40
+
*From*\
41
+
The type of the value to convert.
42
42
43
-
*s*\
44
-
The span to get the raw representation of.
43
+
*from*\
44
+
The value to convert.
45
45
46
46
### Return Value
47
47
48
-
A `span<const byte, S>` to the first item stored in the span where `S` is `{reinterpret_cast<const std::byte*>(s.data()), s.size_bytes()}`
48
+
An object of type `To`. Each bit in the result matches the corresponding bit in `from`, unless there are padding bits in `To`, in which case those bits in the result are unspecified.
0 commit comments