A fairly UB-free set of functions to operate on and convert between arrays of bytelike types.
More...
|
| template<bytelike TO, typename FROM, size_t N = std::dynamic_extent> |
| std::span< TO > | ghassanpl::as_bytelikes (std::span< FROM, N > elements) noexcept |
| | Converts a span of trivial values to a span of bytelike s.
|
| template<typename TO, bytelike FROM> |
| TO | ghassanpl::from_bytelikes (std::span< FROM const > from) |
| | Returns an object whose internal representation is initialized from the argument.
|
| template<typename TO, bytelike FROM> |
| std::span< TO > | ghassanpl::span_from_bytelikes (std::span< FROM > from) |
| | Returns an object whose internal representation is initialized from the argument.
|
| template<bytelike TO, typename T> |
| auto | ghassanpl::as_bytelikes (T &pod) noexcept |
| | Returns a span of bytelike s that represents the internal object representation of the argument.
|
| template<bytelike FROM> |
| constexpr auto | ghassanpl::to_u8 (FROM byte) noexcept |
| | Bit-casts the given bytelike to a uint8_t.
|
| template<bytelike FROM> |
| constexpr auto | ghassanpl::to_char (FROM byte) noexcept |
| | Bit-casts the given bytelike to a char.
|
| template<bytelike FROM> |
| constexpr auto | ghassanpl::to_byte (FROM byte) noexcept |
| | Bit-casts the given bytelike to a std::byte.
|
| template<bytelike FROM> |
| constexpr auto | ghassanpl::to_uchar (FROM byte) noexcept |
| | Bit-casts the given bytelike to a unsigned char.
|
| template<bytelike FROM> |
| constexpr auto | ghassanpl::to_char8 (FROM byte) noexcept |
| | Bit-casts the given bytelike to a char8_t.
|
| template<bytelike FROM, size_t N = std::dynamic_extent> |
| auto | ghassanpl::as_chars (std::span< FROM, N > bytes) noexcept |
| | Returns a span of chars that represents the bytelikes in bytes.
|
| template<bytelike FROM, size_t N = std::dynamic_extent> |
| auto | ghassanpl::as_bytes (std::span< FROM, N > bytes) noexcept |
| | Returns a span of std::bytes that represents the bytelikes in bytes.
|
| template<bytelike FROM, size_t N = std::dynamic_extent> |
| auto | ghassanpl::as_uchars (std::span< FROM, N > bytes) noexcept |
| | Returns a span of unsigned chars that represents the bytelikes in bytes.
|
| template<bytelike FROM, size_t N = std::dynamic_extent> |
| auto | ghassanpl::as_u8s (std::span< FROM, N > bytes) noexcept |
| | Returns a span of uint8_ts that represents the bytelikes in bytes.
|
| template<bytelike FROM, size_t N = std::dynamic_extent> |
| auto | ghassanpl::as_char8s (std::span< FROM, N > bytes) noexcept |
| | Returns a span of char8_ts that represents the bytelikes in bytes.
|
| template<typename T> |
| auto | ghassanpl::as_chars (T const &data) noexcept |
| | Returns a span of chars that represents the internal object representation of the data object.
|
| template<typename T> |
| auto | ghassanpl::as_bytes (T const &data) noexcept |
| | Returns a span of std::bytes that represents the internal object representation of the data object.
|
| template<typename T> |
| auto | ghassanpl::as_uchars (T const &data) noexcept |
| | Returns a span of unsigned chars that represents the internal object representation of the data object.
|
| template<typename T> |
| auto | ghassanpl::as_u8s (T const &data) noexcept |
| | Returns a span of uint8_ts that represents the internal object representation of the data object.
|
| template<typename T> |
| auto | ghassanpl::as_char8s (T const &data) noexcept |
| | Returns a span of char8_ts that represents the internal object representation of the data object.
|
| template<bytelike B, size_t N = std::dynamic_extent> |
| bool | ghassanpl::nth_bit (std::span< B const, N > range, size_t n) noexcept |
| | Returns the value of the nth bit in the range of bytelikes.
|
| template<bytelike B, size_t N = std::dynamic_extent> |
| void | ghassanpl::set_nth_bit (std::span< B, N > range, size_t n, bool value) noexcept |
| | Sets the value of the nth bit in the range of bytelikes.
|
| template<typename T> |
| bool | ghassanpl::nth_bit (T const &pod, size_t n) noexcept |
| | Returns the value of the nth bit in the internal object representation of the pod object.
|
| template<typename T> |
| void | ghassanpl::set_nth_bit (T &pod, size_t n, bool value) noexcept |
| | Sets the value of the nth bit in the internal object representation of the pod object.
|
| template<size_t N, bytelike B, size_t SN = std::dynamic_extent> |
| bool | ghassanpl::nth_bit (std::span< B const, SN > range) noexcept |
| | Returns the value of the Nth bit in the range of bytelikes.
|
| template<size_t N, bytelike B, size_t SN = std::dynamic_extent> |
| void | ghassanpl::set_nth_bit (std::span< B, SN > range, bool value) noexcept |
| | Sets the value of the Nth bit in the range of bytelikes.
|
| template<size_t N, typename T> |
| bool | ghassanpl::nth_bit (T const &pod) noexcept |
| | Returns the value of the Nth bit in the internal object representation of the pod object.
|
| template<size_t N, typename T> |
| void | ghassanpl::set_nth_bit (T &pod, bool value) noexcept |
| | Sets the value of the Nth bit in the internal object representation of the pod object.
|
| template<bytelike B, std::integral T> |
| constexpr auto | ghassanpl::to_bytelike_array (T value_) |
| | A constexpr function that converts an integral value to its constituent bytelikes TODO: This is NOT like a reinterpret_/bit_cast to u8s, because it's not endian-aware.
|
| template<std::integral T> |
| constexpr auto | ghassanpl::to_u8_array (T value) |
| template<size_t ALIGN, bytelike T, size_t N = std::dynamic_extent> |
| auto | ghassanpl::align_front_to (std::span< T, N > bytes) noexcept -> align_front_to_result< T > |
| | Splits the argument span into two spans, the first one being the prefix, the second one having its data pointer aligned to the given alignment.
|
| template<size_t ALIGN, bytelike T, size_t N = std::dynamic_extent> |
| constexpr auto | ghassanpl::align_back_to (std::span< T, N > bytes) noexcept -> align_back_to_result< T > |
| | Splits the argument span into two spans, the first one having its size aligned to the given alignment, the second one being the suffix.
|
| template<size_t ALIGN, bytelike T, size_t N = std::dynamic_extent> |
| auto | ghassanpl::align_to (std::span< T, N > bytes) noexcept -> align_to_result< T > |
| | Splits the argument span into three spans, the first one being the prefix, the second one having its data and size aligned to the given alignment, the third one being the suffix.
|
| template<typename TO, bytelike B, size_t N = std::dynamic_extent> |
| auto | ghassanpl::aligned_span_cast (std::span< B, N > bytes) noexcept -> align_to_result< B, TO > |
| | Splits the argument span into three spans, the first one being the prefix, the second one capable of storing one ore more objects of type TO with the proper alignment, and the third one being the suffix.
|
| template<typename TO, bytelike B, size_t N = std::dynamic_extent> |
| auto | ghassanpl::aligned_span_cast_and_construct (std::span< B, N > bytes) noexcept -> align_to_result< B, TO > |
| | Does the same as aligned_span_cast but then default-constructs the elements of the of middle span.
|
A fairly UB-free set of functions to operate on and convert between arrays of bytelike types.