https://github.com/curve/rebind
๐ฒ Simple, compiler agnostic, C++23 reflection library (for aggregates and enums)
https://github.com/curve/rebind
cpp-reflection cpp23 cpp23-library reflection
Last synced: 9 months ago
JSON representation
๐ฒ Simple, compiler agnostic, C++23 reflection library (for aggregates and enums)
- Host: GitHub
- URL: https://github.com/curve/rebind
- Owner: Curve
- License: mit
- Created: 2024-07-07T18:15:14.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2025-03-11T09:00:01.000Z (10 months ago)
- Last Synced: 2025-04-06T03:44:14.584Z (9 months ago)
- Topics: cpp-reflection, cpp23, cpp23-library, reflection
- Language: C++
- Homepage:
- Size: 116 KB
- Stars: 6
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## ๐ Description
_Rebind_ is a simple, tiny C++23 reflection library for aggregates and enums.
This library is fully compiler agnostic as it figures out how to demangle given types at compile time.
## ๐ฆ Installation
* Using [CPM](https://github.com/cpm-cmake/CPM.cmake)
```cmake
CPMFindPackage(
NAME rebind
VERSION 5.1.0
GIT_REPOSITORY "https://github.com/Curve/rebind"
)
```
* Using FetchContent
```cmake
include(FetchContent)
FetchContent_Declare(rebind GIT_REPOSITORY "https://github.com/Curve/rebind" GIT_TAG v5.0.0)
FetchContent_MakeAvailable(rebind)
target_link_libraries( cr::rebind)
```
## ๐ Examples
https://github.com/Curve/rebind/blob/d8b79fa7a8fe0fd155f0f7c2f896052649210b26/tests/name.test.cpp#L9-L11
https://github.com/Curve/rebind/blob/d8b79fa7a8fe0fd155f0f7c2f896052649210b26/tests/enum.test.cpp#L22-L33
https://github.com/Curve/rebind/blob/d8b79fa7a8fe0fd155f0f7c2f896052649210b26/tests/member.test.cpp#L37-L45
> ๐งช For more examples see [tests](tests/)
## ๐ Documentation
```cpp
template
static constexpr auto type_name = /*...*/;
```
> **Returns**: Human readable name of type `T`
```cpp
template
static constexpr auto nttp_name = /*...*/;
```
> **Returns**: Human readable name of the given nttp `T`
---
```cpp
template
static constexpr auto arity = /*...*/;
```
> **Returns**: Count of members of `T`
```cpp
template
constexpr auto to_tuple(T &value);
```
> **Returns**: A tuple of references to all members of the given `value`
---
```cpp
template
static constexpr auto members = /*...*/;
```
> **Returns**: A `rebind::member` object for each member present in the aggregate
> **Contains**: The `type`, `name` and `index`
```cpp
template
static constexpr auto member_name = /*...*/;
```
> **Returns**: The member name of the given member pointer
---
```cpp
template
static constexpr auto enum_name = /*...*/;
```
> **Returns**: The name of the given enum value
> **Note**: To get the name of an enum-type use `rebind::type_name` instead
```cpp
template
static constexpr auto enum_values = /*...*/;
```
> **Returns**: All values of the given enum `T` (specialize `rebind::search_min` / `rebind::search_max` to tweak the search range)