repr 0.1
Reconstructable string representations and more
Loading...
Searching...
No Matches
visit_aggregate.h
Go to the documentation of this file.
1#pragma once
2#include <type_traits>
3#include "arity.h"
4
5namespace librepr::detail {
6
7// NOLINTBEGIN
8template <typename T, typename V>
9 requires(std::is_aggregate_v<std::remove_cvref_t<T>> && !std::is_array_v<std::remove_cvref_t<T>>)
10constexpr auto visit_aggregate(V&& visitor, T&& object) {
11 constexpr auto member_count = arity<std::remove_cvref_t<T>>;
12 if constexpr (member_count == 0) {
13 return visitor();
14 } else if constexpr (member_count == 1) {
15 auto& [member_0] = object;
16 return visitor(member_0);
17 } else if constexpr (member_count == 2) {
18 auto& [member_0, member_1] = object;
19 return visitor(member_0, member_1);
20 } else if constexpr (member_count == 3) {
21 auto& [member_0, member_1, member_2] = object;
23 } else if constexpr (member_count == 4) {
26 } else if constexpr (member_count == 5) {
29 } else if constexpr (member_count == 6) {
32 } else if constexpr (member_count == 7) {
35 } else if constexpr (member_count == 8) {
38 } else if constexpr (member_count == 9) {
41 } else if constexpr (member_count == 10) {
44 } else if constexpr (member_count == 11) {
48 member_10);
49 } else if constexpr (member_count == 12) {
54 } else if constexpr (member_count == 13) {
59 } else if constexpr (member_count == 14) {
64 } else if constexpr (member_count == 15) {
69 } else if constexpr (member_count == 16) {
74 } else if constexpr (member_count == 17) {
79 } else if constexpr (member_count == 18) {
84 } else if constexpr (member_count == 19) {
89 } else if constexpr (member_count == 20) {
95 member_19);
96 } else if constexpr (member_count == 21) {
103 } else if constexpr (member_count == 22) {
110 } else if constexpr (member_count == 23) {
117 } else if constexpr (member_count == 24) {
124 } else if constexpr (member_count == 25) {
131 } else if constexpr (member_count == 26) {
138 } else if constexpr (member_count == 27) {
145 } else if constexpr (member_count == 28) {
152 } else if constexpr (member_count == 29) {
159 member_28);
160 } else if constexpr (member_count == 30) {
164 member_29] = object;
169 } else if constexpr (member_count == 31) {
173 member_30] = object;
178 } else if constexpr (member_count == 32) {
187 } else if constexpr (member_count == 33) {
196 } else if constexpr (member_count == 34) {
205 } else if constexpr (member_count == 35) {
214 } else if constexpr (member_count == 36) {
223 } else if constexpr (member_count == 37) {
232 } else if constexpr (member_count == 38) {
241 member_37);
242 } else if constexpr (member_count == 39) {
252 } else if constexpr (member_count == 40) {
257 member_39] = object;
263 } else if constexpr (member_count == 41) {
268 member_40] = object;
274 } else if constexpr (member_count == 42) {
285 } else if constexpr (member_count == 43) {
296 } else if constexpr (member_count == 44) {
307 } else if constexpr (member_count == 45) {
318 } else if constexpr (member_count == 46) {
329 } else if constexpr (member_count == 47) {
340 member_46);
341 } else if constexpr (member_count == 48) {
353 } else if constexpr (member_count == 49) {
365 } else if constexpr (member_count == 50) {
371 member_49] = object;
378 } else if constexpr (member_count == 51) {
384 member_50] = object;
391 } else if constexpr (member_count == 52) {
404 } else if constexpr (member_count == 53) {
417 } else if constexpr (member_count == 54) {
430 } else if constexpr (member_count == 55) {
443 } else if constexpr (member_count == 56) {
456 member_55);
457 } else if constexpr (member_count == 57) {
471 } else if constexpr (member_count == 58) {
485 } else if constexpr (member_count == 59) {
499 } else if constexpr (member_count == 60) {
506 member_59] = object;
514 } else if constexpr (member_count == 61) {
521 member_60] = object;
529 } else if constexpr (member_count == 62) {
544 } else if constexpr (member_count == 63) {
559 } else if constexpr (member_count == 64) {
574 }
575}
576// NOLINTEND
577} // namespace librepr::detail
Definition assert.h:89
constexpr auto visit_aggregate(V &&visitor, T &&object)
Definition visit_aggregate.h:10
std::string code_for()
Definition repr:39