Shamrock 2025.10.0
Astrophysical Code
Loading...
Searching...
No Matches
Namespaces | Functions
memory.hpp File Reference
#include "shambase/aliases_int.hpp"
#include "shambase/exception.hpp"
#include "shambase/string.hpp"
#include <memory>
#include <optional>
#include <utility>
+ Include dependency graph for memory.hpp:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

namespace  shambase
 namespace for basic c++ utilities
 

Functions

template<class T , class AccU8 >
void shambase::store_u8 (AccU8 &acc, u64 idx_write, T a)
 Store a value of type T in a byte buffer.
 
template<class T , class AccU8 >
shambase::load_u8 (AccU8 &acc, u64 ptr_load)
 load a value of type T from a byte buffer
 
template<class T , class TAcc >
void shambase::store_conv (TAcc *acc, T a)
 pointer cast store the value
 
template<class T , class TAcc >
shambase::load_conv (TAcc *acc)
 pointer cast load from a pointer
 
template<class T >
T & shambase::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_error if the std::unique_ptr does not hold anything.
 
template<class T >
T & shambase::get_check_ref (const std::shared_ptr< T > &ptr, SourceLocation loc=SourceLocation())
 Takes a std::shared_ptr and returns a reference to the object it holds. It throws a std::runtime_error if the std::shared_ptr does not hold anything.
 
template<class T >
const T & shambase::get_check_ref (const std::optional< T > &ptr, SourceLocation loc=SourceLocation())
 Get reference to object held by the unique ptr, and throw if nothing is held.
 
template<class T >
T & shambase::get_check_ref (std::optional< T > &ptr, SourceLocation loc=SourceLocation())
 Same overload but for non const case.
 
template<class T >
T & shambase::get_check_ref (T *ptr, SourceLocation loc=SourceLocation())
 Takes a raw pointer and returns a reference to the object it points to. It throws a std::runtime_error if the pointer is null.
 
template<class T >
const T & shambase::get_check_ref (const T *ptr, SourceLocation loc=SourceLocation())
 same overload but for const pointer
 
template<typename T >
auto shambase::extract_value (std::optional< T > &o, SourceLocation loc=SourceLocation()) -> T
 Extracts the content out of an optional.
 
template<typename T >
auto shambase::extract_pointer (std::unique_ptr< T > &o, SourceLocation loc=SourceLocation()) -> T
 extract content out of unique_ptr
 
template<int n, class T >
std::array< T, n > shambase::convert_to_array (std::vector< T > &in)
 Convert a vector to an array of size n.
 

Detailed Description

Author
Timothée David–Cléris (tim.s.nosp@m.hamr.nosp@m.ock@p.nosp@m.roto.nosp@m.n.me)

Definition in file memory.hpp.