20template <
typename To,
typename From>
22 if constexpr (std::is_same<To, From>::value) {
26 static_assert(std::is_integral<To>::value && std::is_unsigned<To>::value,
27 "converted layout values must be unsigned integers");
28 static_assert(std::is_integral<From>::value && std::is_unsigned<From>::value,
29 "remote layout storage must be an unsigned integer");
31 if constexpr (
sizeof(From) >
sizeof(To)) {
32 if (value >
static_cast<From
>(std::numeric_limits<To>::max()))
35 out =
static_cast<To
>(value);
63 static_assert(std::is_nothrow_copy_constructible<Callback>::value,
64 "remote layout callbacks must be nothrow copy-constructible");
68 template <
typename... Inputs>
70 Inputs... inputs)
const noexcept {
72 std::is_nothrow_invocable_r<bool,
const Callback &,
address_space_ref, uintptr_t, Value &, Inputs...>::value,
73 "remote layout callback must be noexcept and return bool");
74 return callback_(space, object_address, out, inputs...);
90 template <
typename... Inputs>
91 [[nodiscard]]
bool read(
address_space_ref space, uintptr_t object_address, Value &out, Inputs...) const noexcept {
109 template <
typename... Inputs>
111 Inputs... inputs)
const noexcept {
112 return accessor_.
read(space, object_address, out, inputs...);
122template <
typename Value,
typename Callback>
130template <
typename Value,
typename Stored = Value>
Type-erased remote address-space access and remote string/object views.
Type-erased, two-word handle to a remote address space.
Definition address_space.hpp:204
expected< void, address_space_error > read(uintptr_t addr, T &out_obj) const noexcept
Reads a trivially-copyable object from the remote address space.
Definition address_space.hpp:314
bool read(address_space_ref space, uintptr_t object_address, Value &out, Inputs...) const noexcept
Definition remote_layout_accessor.hpp:91
Value value_type
Definition remote_layout_accessor.hpp:86
constexpr remote_layout_accessor(remote_layout_offset< Stored > source) noexcept
Definition remote_layout_accessor.hpp:88
Reads a remote layout property through a retained callback.
Definition remote_layout_accessor.hpp:59
Value value_type
Definition remote_layout_accessor.hpp:61
constexpr remote_layout_accessor(Callback callback) noexcept
Definition remote_layout_accessor.hpp:66
bool read(address_space_ref space, uintptr_t object_address, Value &out, Inputs... inputs) const noexcept
Definition remote_layout_accessor.hpp:69
Uniform query wrapper around callback and typed-offset accessors.
Definition remote_layout_accessor.hpp:105
constexpr remote_layout_query(Source source) noexcept
Definition remote_layout_accessor.hpp:107
bool operator()(address_space_ref space, uintptr_t object_address, Value &out, Inputs... inputs) const noexcept
Definition remote_layout_accessor.hpp:110
RELOCO_BEGIN_UNSAFE_CODE constexpr uintptr_t add_address_offset(uintptr_t address, ptrdiff_t offset) noexcept
Definition address_space.hpp:52
constexpr bool convert_remote_layout_value(From value, To &out) noexcept
Definition remote_layout_accessor.hpp:21
constexpr auto make_remote_offset_query(ptrdiff_t offset) noexcept
Creates a query backed by a typed remote-object offset.
Definition remote_layout_accessor.hpp:131
constexpr auto make_remote_layout_query(Callback callback) noexcept
Creates a query backed by a callback retained by value.
Definition remote_layout_accessor.hpp:123
Describes a property stored at a fixed offset in a remote object.
Definition remote_layout_accessor.hpp:46
ptrdiff_t offset
Definition remote_layout_accessor.hpp:47