codex
Loading...
Searching...
No Matches
fields.hpp
Go to the documentation of this file.
1
#ifndef CODEX_REFLECTION_FIELDS_DETAIL_HPP
2
#define CODEX_REFLECTION_FIELDS_DETAIL_HPP
3
4
#include <cstdio>
5
#include <tuple>
6
#include <utility>
7
8
namespace
codex::refl::detail
{
9
17
template
<auto>
18
struct
to_any {
19
template
<
typename
T>
constexpr
operator
T
(
void
);
20
};
21
27
template
<std::
size_t
N>
struct
field_tuple_impl
;
28
29
// Could potentially be implemented in a more concise manner with auxiliary
30
// infrastructure such as Boost.Preprocessor.
31
#define X(n, ...) \
32
template<> \
33
struct field_tuple_impl<n> { \
34
decltype(auto) operator()(auto &&x) { \
35
auto &&[__VA_ARGS__] = std::forward<decltype(x)>(x); \
36
return std::tie(__VA_ARGS__); \
37
} \
38
};
39
X
(1,
_0
)
40
X
(2,
_0
,
_1
)
41
X
(3,
_0
,
_1
,
_2
)
42
X
(4,
_0
,
_1
,
_2
, _3)
43
#undef X
44
45
}
46
47
#endif
T
#define T(f, T, C)
Definition
bench.cpp:136
codex::refl::detail
Definition
fields.hpp:8
codex::refl::detail::_2
_1 _2
Definition
fields.hpp:42
codex::refl::detail::_0
_0
Definition
fields.hpp:40
codex::refl::detail::_1
_1 _1
Definition
fields.hpp:42
X
#define X(n,...)
Definition
fields.hpp:31
X
Definition
reader.hpp:12
codex::refl::detail::field_tuple_impl
Implementation of creating a std::tuple from the fields of a struct.
Definition
fields.hpp:27
reflection
detail
fields.hpp
Generated by
1.11.0