rexlib 0.1.0
Device-agnostic array computing library for CryoEM and CryoET image processing, with a pluggable backend architecture
Loading...
Searching...
No Matches
byte.hpp
1// SPDX-License-Identifier: GPL-3.0-only
2
3#pragma once
4
5#include "../platform/attributes.hpp"
6#include "../platform/constexpr.hpp"
7
8#include <type_traits>
9#include <cstdint>
10#include <functional>
11#include <iostream>
12
13namespace rexlib
14{
15
24
25REXLIB_CONSTEXPR uint8_t as_uint8(byte b) noexcept;
26REXLIB_CONSTEXPR byte as_byte(uint8_t b) noexcept;
27
34template <typename T>
35byte* as_bytes(T* ptr) noexcept;
36
43template <typename T>
44const byte* as_bytes(const T* ptr) noexcept;
45
46template <class IntegerType>
47REXLIB_CONSTEXPR byte operator<<(byte b, IntegerType shift) noexcept;
48template <class IntegerType>
49REXLIB_CONSTEXPR byte operator>>(byte b, IntegerType shift) noexcept;
50template <class IntegerType>
51REXLIB_CONSTEXPR byte& operator<<=(byte& b, IntegerType shift) noexcept;
52template <class IntegerType>
53REXLIB_CONSTEXPR byte& operator>>=(byte& b, IntegerType shift) noexcept;
54
55REXLIB_CONSTEXPR byte operator~(byte b) noexcept;
56REXLIB_CONSTEXPR byte operator|(byte lhs, byte rhs) noexcept;
57REXLIB_CONSTEXPR byte operator&(byte lhs, byte rhs) noexcept;
58REXLIB_CONSTEXPR byte operator^(byte lhs, byte rhs) noexcept;
59REXLIB_CONSTEXPR byte& operator|=(byte& lhs, byte rhs) noexcept;
60REXLIB_CONSTEXPR byte& operator&=(byte& lhs, byte rhs) noexcept;
61REXLIB_CONSTEXPR byte& operator^=(byte& lhs, byte rhs) noexcept;
62
63REXLIB_CONSTEXPR std::size_t get_byte_bits() noexcept;
64
66REXLIB_CONSTEXPR void to_hex(byte b, C &high, C &low) noexcept;
67
69std::basic_ostream<T>& operator<<(std::basic_ostream<T>& os, const byte& b);
70
71} // namespace rexlib
72
73template <>
74struct std::hash<rexlib::byte>
75{
76 REXLIB_CONSTEXPR size_t operator()(rexlib::byte b) const noexcept;
77};
78
79#include "byte.inl"
#define REXLIB_MAY_ALIAS
Declares a type through which objects of any other type may be accessed, as they may through a charac...
Definition attributes.hpp:131
Container for multidimensional numeric data.
Definition array.hpp:31
Arrays, the operations on them and the devices that run those operations.
Definition cpu_device.hpp:10
byte * as_bytes(T *ptr) noexcept
View an object as the bytes it is stored in.
byte
A byte of memory.
Definition byte.hpp:23