-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathstruct_attribute.cpp
More file actions
40 lines (35 loc) · 1.28 KB
/
Copy pathstruct_attribute.cpp
File metadata and controls
40 lines (35 loc) · 1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include "serdepp/serde.hpp"
#include "serdepp/adaptor/fmt.hpp"
namespace serde::attribute {
namespace detail {
struct tttt {
template <typename T, typename serde_ctx, typename Next, typename... Attributes>
constexpr inline void from(serde_ctx& ctx, T& data, std::string_view key,
Next&& next_attr, Attributes&& ...remains) const{
fmt::print("from\n");
next_attr.from(ctx, data, key, remains...);
}
template <typename T, typename serde_ctx, typename Next, typename... Attributes>
constexpr inline void into(serde_ctx& ctx, T& data, std::string_view key,
Next&& next_attr, Attributes&& ...remains) const{
fmt::print("into\n");
next_attr.into(ctx, data, key, remains...);
}
};
}
[[maybe_unused]] constexpr static auto tttt = detail::tttt{};
}
struct test_{
DERIVE_SERDE(test_, .attributes(tttt,tttt)
(&Self::test, "test")
[attributes(make_optional)]
(&Self::a, "a")
)
int test;
bool a;
};
int main(int argc, char *argv[])
{
fmt::print("{}\n",test_{1, false});
return 0;
}