1 #ifndef MF_ELEM_TUPLE_H_
2 #define MF_ELEM_TUPLE_H_
15 template<
typename First_elem,
typename... Other_elems>
31 elem_tuple(
const First_elem& first,
const Other_elems&... others) :
44 constexpr
static std::size_t
size() {
return 1 +
sizeof...(Other_elems); }
51 template<
typename First_elem>
77 constexpr
static std::size_t
size() {
return 1; }
85 template<std::ptrdiff_t Index,
typename Tuple>
86 struct elem_tuple_accessor;
89 template<std::ptrdiff_t Index,
typename First_elem,
typename... Other_elems>
90 struct elem_tuple_accessor<Index, elem_tuple<First_elem, Other_elems...>> {
91 using tuple_type = elem_tuple<First_elem, Other_elems...>;
92 using others_tuple_type =
typename tuple_type::others_tuple_type;
94 static auto&
get(tuple_type& tup) {
98 static const auto&
get(
const tuple_type& tup) {
102 constexpr
static std::ptrdiff_t offset() {
103 return offsetof(tuple_type, others_) + elem_tuple_accessor<Index - 1, others_tuple_type>::offset();
108 template<
typename First_elem,
typename... Other_elems>
109 struct elem_tuple_accessor<0, elem_tuple<First_elem, Other_elems...>> {
110 using tuple_type = elem_tuple<First_elem, Other_elems...>;
112 static auto&
get(tuple_type& tup) {
115 static const auto&
get(
const tuple_type& tup) {
118 constexpr
static std::ptrdiff_t offset() {
126 template<
typename T,
typename Tuple>
129 template<
typename T,
typename First_elem,
typename... Other_elems>
133 template<
typename T,
typename... Other_elems>
139 template<std::size_t Index,
typename First_elem,
typename... Other_elems>
140 const auto&
get(
const elem_tuple<First_elem, Other_elems...>& tup) {
141 using tuple_type = std::decay_t<decltype(tup)>;
145 template<std::size_t Index,
typename First_elem,
typename... Other_elems>
147 using tuple_type = std::decay_t<decltype(tup)>;
153 template<
typename T,
typename First_elem,
typename... Other_elems>
154 const auto&
get(
const elem_tuple<First_elem, Other_elems...>& tup) {
155 using tuple_type = std::decay_t<decltype(tup)>;
156 constexpr std::size_t index = elem_tuple_index<T, tuple_type>;
160 template<
typename T,
typename First_elem,
typename... Other_elems>
161 auto&
get(elem_tuple<First_elem, Other_elems...>& tup) {
162 using tuple_type = std::decay_t<decltype(tup)>;
163 constexpr std::size_t index = elem_tuple_index<T, tuple_type>;
169 template<std::
size_t Index,
typename Tuple>
172 template<std::size_t Index,
typename First_elem,
typename... Other_elems>
174 detail::elem_tuple_accessor<Index,
elem_tuple<First_elem, Other_elems...>>::offset();
178 template<
typename... Elems>
185 template<
typename... Elems>
First_elem first_
Definition: elem_tuple.h:53
elem_tuple< Elems...> make_elem_tuple(const Elems &...elems)
Make elem_tuple with elements elems.
Definition: elem_tuple.h:179
bool is_null() const noexcept
Definition: elem_tuple.h:46
elem_tuple(const First_elem &first, const Other_elems &...others)
Definition: elem_tuple.h:31
static constexpr std::size_t size()
Definition: elem_tuple.h:44
constexpr std::ptrdiff_t elem_tuple_offset
Offset in bytes of element at index Index in elem_tuple type Tuple.
Definition: elem_tuple.h:170
Heterogeneous tuple of items.
Definition: elem_tuple.h:16
others_tuple_type others_
Definition: elem_tuple.h:24
elem_tuple(const First_elem &first)
Definition: elem_tuple.h:64
First_elem first_
Definition: elem_tuple.h:23
elem_tuple & operator=(const elem_tuple &)=default
friend bool operator!=(const elem_tuple &a, const elem_tuple &b)
Definition: elem_tuple.h:73
Elem traits base class with the required members.
Definition: elem.h:14
friend bool operator==(const elem_tuple &a, const elem_tuple &b)
Definition: elem_tuple.h:37
Default elem traits, using Elem as standard layout scalar type.
Definition: elem.h:30
static constexpr bool is_nullable
Definition: elem.h:23
auto & get(elem_tuple< First_elem, Other_elems...> &tup)
Definition: elem_tuple.h:146
bool is_null() const noexcept
Definition: elem_tuple.h:79
constexpr std::ptrdiff_t elem_tuple_index
Index of first element of type T in elem_tuple type Tuple.
Definition: elem_tuple.h:127
static constexpr bool is_nullable
Definition: elem_tuple.h:21
static constexpr std::size_t size()
Definition: elem_tuple.h:77
static constexpr bool is_tuple
Definition: elem.h:19
friend bool operator==(const elem_tuple &a, const elem_tuple &b)
Definition: elem_tuple.h:70
friend bool operator!=(const elem_tuple &a, const elem_tuple &b)
Definition: elem_tuple.h:40