boostorg / boostorg/describe

Add reflection on attributes

Open
#13 9 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
78
Forks
50
PR merge metrics
No merged PRs in 30d

Description

Following up discussion on [cpplang](https://cpplang.slack.com/archives/C27KZLB0X/p1620262809119900), it would be interesting to have a way to extend *member descriptors* with custom information (think units, text description). User-defined [attributes](https://en.cppreference.com/w/cpp/language/attributes) seems the right tool to express this custom information:

```c++
[[units(cm), description("this is sparta")]] int x;
```

The emulation of the reflection would look something like:

```c++
BOOST_DESCRIBE_MEMATTR(x, units(cm), description("this is sparta")) int x;
```

We would have `describe_member_attributes` returns `L`, where `D` is a member descriptor.

and `Ai` is an *attribute descriptor* of the form

```c++
struct Ai
{
static constexpr char const * name = "units";
static constexpr char const * value = "cm"; /* string attribute only for now */
};
```

As pointed out by @pdimov, there is a proposal about attribute reflection that introduces [typed attributes](
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2020/p1887r1.pdf).

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.