codex
Loading...
Searching...
No Matches
fields.hpp
Go to the documentation of this file.
1#ifndef CODEX_REFLECTION_FIELDS_HPP
2#define CODEX_REFLECTION_FIELDS_HPP
3
4#include "detail/fields.hpp"
5
6namespace codex::refl {
7
15template<typename T, std::size_t ...N>
16constexpr std::size_t field_count(void) {
17 return sizeof...(N) - 1;
18}
19
27template<typename T, std::size_t ...N>
28requires(requires { T{detail::to_any<N>{}...}; })
29constexpr std::size_t field_count(void) {
30 return field_count<T, N..., sizeof...(N)>();
31}
32
34template<typename T>
35auto field_tuple(T &&t) {
36 constexpr auto n = field_count<std::decay_t<T>>();
37 return detail::field_tuple_impl<n>{}(std::forward<T>(t));
38}
39
41template<typename T>
42using field_tuple_t = decltype(field_tuple(std::declval<T>()));
43
44}
45
46#endif
#define T(f, T, C)
Definition bench.cpp:136
Definition main.cpp:7
Definition fields.hpp:8
decltype(field_tuple(std::declval< T >())) field_tuple_t
Alias of the tuple type returned by field_tuple for type T.
Definition fields.hpp:42
constexpr std::size_t field_count(void)
Number of fields in the struct T.
Definition fields.hpp:16
auto field_tuple(T &&t)
Constructs a tuple of references to each field of T, in order.
Definition fields.hpp:35
codex::refl::field_tuple_t< E > T
Definition soa.cpp:9
#define t(a)
Definition std2.c:10