-
Notifications
You must be signed in to change notification settings - Fork 71
/
main.cpp
35 lines (25 loc) · 905 Bytes
/
main.cpp
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
#include <USRefl/USRefl.h>
// Vec's definition
// and Vec's reflection declaration (Vec_AutoRefl.inl, generated by CMake before building)
#include "Vec.h"
using namespace Ubpa::Nested;
#include <iostream>
using namespace Ubpa::USRefl;
using namespace std;
int main() {
cout << TypeInfo<Vec<float>>::name << endl;
TypeInfo<Vec<float>>::fields.ForEach([](auto field) {
cout << field.name << endl;
});
constexpr auto y_field = TypeInfo<Vec<float>>::fields.Find(TSTR("y"));
static_assert(y_field.name == "y");
static_assert(TypeInfo<Vec<float>>::fields.Contains(TSTR("x")));
TypeInfo<Vec<float>>::attrs.ForEach([](auto attr) {
cout << "name : " << attr.name << endl;
if constexpr (!attr.has_value)
cout << "value : " << attr.value << endl;
});
TypeInfo<Vec<float>>::ForEachVarOf(Vec<float>{ 1,2 }, [](auto field, auto&& var) {
cout << field.name << " : " << var << endl;
});
}