__ __ _______..______ _______ _______ __
| | | | / || _ \ | ____|| ____|| |
| | | | | (----`| |_) | | |__ | |__ | |
| | | | \ \ | / | __| | __| | |
| `--' | .----) | | |\ \----.| |____ | | | `----.
\______/ |_______/ | _| `._____||_______||__| |_______|
⭐ Star us on GitHub — it helps!
Ubpa Static Reflection
Header-only, tiny (99 lines) and powerful C++17 static reflection library.
- header-only, tiny (99 lines) and powerful (USRefl_99.h)
- noninvasive
- basic
- (non-static / static) member variable
- (non-static / static) member function
- attribute
- enum
- string <-> enumerator
- static dispatch
- template
- inheritance
- diamond inheritance
- iterate bases recursively
- virtual inheritance
- parser
run it online : compiler explorer
#include <USRefl/USRefl.h>
#include <iostream>
using namespace Ubpa::USRefl;
using namespace std;
// [[...]] act as (structured) comments
// they are useless in the code
struct [[size(8)]] Point {
[[not_serialize]]
float x;
[[info("hello")]]
float y;
};
// declaration
template<>
struct TypeInfo<Point> : TypeInfoBase<Point> {
// if you use <USRefl/USRefl.h>, the name is declared by TypeInfoBase<Point>
// if you use <USRefl_99.h>, you should declare it here.
// static constexpr std::string_view name = "struct Point";