Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2021-02-25 18:05:35


Bjorn Reese wrote:
> On 2021-02-23 19:56, Peter Dimov via Boost wrote:
>
> > Describe is a library that allows programmers to annotate their
> > classes (and enumerations) in order to enable simple reflection. It
> > provides a very important fundament on which other libraries can build
> > upon to provide automatic support for user-defined types.
>
> How does it differ from Boost.Fusion?

* It supports more complete metadata, such as base classes, member
functions and access control. (The RPC example demonstrates a use for
functions.)

https://pdimov.github.io/describe/doc/html/describe.html#example_json_rpc

* The metadata has the member name which enables easier access to it.
In Fusion, you can retrieve the member name but it's less convenient.

https://gist.github.com/meetingcpp/a06e0ca694b57afb6271445a8d833722

* Boost.Fusion gives you a Fusion sequence, which you then manipulate
using Fusion primitives. Describe gives you a specific type of a documented
form that can be manipulated with Mp11 primitives (as it's a type list) but
can also be manipulated using ordinary C++ metaprogramming. Most simple
uses require no metaprogramming at all, just an mp_for_each.

The goal here is to make is as easy and painless as possible for other
libraries to describe their types (in order to enable users to take advantage
of the metadata). Describe is a lightweight dependency, almost standalone
(only needs Mp11 at present), and will eventually become truly standalone.

The aspiration here is to establish a de-facto standard for annotating types.
My initial goal was also to aim for a de-jure standard eventually, i.e. add the
describe_* primitives to <type_traits>, but given the current state of C++
reflection, realistically, this is not going to happen. But it won't hurt to still
do the work as if it did have a chance to happen, because who knows.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk