42 template<
class T,
class AccU8>
44 constexpr u64 szT =
sizeof(T);
45 u8 *bytes = (
u8 *) &a;
47 for (
u64 i = 0; i < szT; i++) {
48 acc[idx_write + i] = bytes[i];
61 template<
class T,
class AccU8>
63 constexpr u64 szT =
sizeof(T);
65 u8 *bytes = (
u8 *) &ret;
67 for (
u64 i = 0; i < szT; i++) {
68 bytes[i] = acc[ptr_load + i];
81 template<
class T,
class TAcc>
95 template<
class T,
class TAcc>
182 "Can not get reference to null pointer", loc);
192 "Can not get reference to null pointer", loc);
216 "the value cannot be extracted, as the optional is empty", loc);
218 return std::exchange(o, std::nullopt).value();
232 "the value cannot be extracted, as the unique_ptr is empty", loc);
234 std::unique_ptr<T> tmp = std::exchange(o, {});
235 return T(std::move(*tmp));
247 template<
int n,
class T>
249 if (in.size() != n) {
251 "you've input values with the wrong size, input size = {}, wanted = {}",
256 std::array<T, n> tmp;
258 for (
u32 i = 0; i < n; i++) {
std::uint8_t u8
8 bit unsigned integer
std::uint32_t u32
32 bit unsigned integer
std::uint64_t u64
64 bit unsigned integer
This header file contains utility functions related to exception handling in the code.
namespace for basic c++ utilities
void store_u8(AccU8 &acc, u64 idx_write, T a)
Store a value of type T in a byte buffer.
auto extract_value(std::optional< T > &o, SourceLocation loc=SourceLocation()) -> T
Extracts the content out of an optional.
std::array< T, n > convert_to_array(std::vector< T > &in)
Convert a vector to an array of size n.
T load_conv(TAcc *acc)
pointer cast load from a pointer
T & get_check_ref(const std::unique_ptr< T > &ptr, SourceLocation loc=SourceLocation())
Takes a std::unique_ptr and returns a reference to the object it holds. It throws a std::runtime_erro...
ExcptTypes make_except_with_loc(std::string message, SourceLocation loc=SourceLocation{})
Create an exception with a message and a location.
auto extract_pointer(std::unique_ptr< T > &o, SourceLocation loc=SourceLocation()) -> T
extract content out of unique_ptr
T load_u8(AccU8 &acc, u64 ptr_load)
load a value of type T from a byte buffer
void store_conv(TAcc *acc, T a)
pointer cast store the value
provide information about the source location