1#ifndef CODEX_LAMBDA_MUTABLE_H
2#define CODEX_LAMBDA_MUTABLE_H
14template<
typename T>
concept arithmetic = std::is_arithmetic_v<T>;
18 {
return static_cast<const std::byte*
>(
p); }
21template<arithmetic T>
inline auto arg_size(
const T&) {
return sizeof(
T); }
27inline auto arg_size(
const std::ranges::sized_range
auto &
r)
28 {
return r.size() *
sizeof(
decltype(*begin(
r))); }
31inline auto arg_ptr(
const std::ranges::range
auto &
r)
39 std::memcpy(this->p,
arg_ptr(
x), *this->s);
40 this->p += *this->s++;
52 const std::array sizes = {arg_size(ts)...};
53 v->resize(std::reduce(begin(sizes), end(sizes)));
54 auto copy = [
p = v->data(),
s = sizes.
data()](
const auto &
x)
mutable
55 { std::memcpy(
p, arg_ptr(
x), *
s);
p += *
s++; };
63 const std::array sizes = {arg_size(ts)...};
64 v->resize(std::reduce(begin(sizes), end(sizes)));
65 function_obj copy = {v->data(), sizes.data()};
#define T(f, T, C)
Definition bench.cpp:136
Concept equivalent of the standard type trait.
Definition mutable.hpp:14
#define x
Definition gcc14.c:1
auto arg_ptr(const arithmetic auto &t)
Overload set that determines the address of its argument's content.
Definition mutable.hpp:24
auto as_bytes(const void *p)
Helper function to reduce the number of casts.
Definition mutable.hpp:17
auto arg_size(const T &)
Overload set that determines the size in bytes of its argument.
Definition mutable.hpp:21
void copy_mutable_lambda(const auto &...ts, std::vector< std::byte > *v)
memcpyes each ts value into v (using a lambda expression).
Definition mutable.hpp:51
void copy_function_object(const auto &...ts, std::vector< std::byte > *v)
memcpyes each ts value into v (using a function object).
Definition mutable.hpp:62
codex::refl::field_tuple_t< E > T
Definition soa.cpp:9
#define r(x, y)
Definition std2.c:13
#define p()
Definition std2.c:11
#define t(a)
Definition std2.c:10
std::byte * p
Definition mutable.hpp:36
void operator()(const auto &x)
Definition mutable.hpp:38
const std::size_t * s
Definition mutable.hpp:37
constexpr const char * data(void) const
Definition utils.hpp:18
constexpr fixed_string s
Definition test.cpp:6