Skip to content

Library Implementation Details

Wyatt Childers edited this page Feb 5, 2019 · 1 revision

Preface

For advanced use cases, it may be necessary to interface with the library's implementation details. As our implementation matures, and the libraries along with it, this should become exceedingly rare, unless the use case is writing a library of your own based on these implementation details.

It is advised you only resort to direct interaction if absolutely necessary, and otherwise utilize our existing headers -- experimental/meta and experimental/compiler.

Our library functions are implemented via compiler intrinsics. Namely, __reflect and __reflect_mod. There are currently virtually no safeguards around these intrinsics, meaning you can and should expect to break things if you use them directly.

reflect

__reflect is used for queries that obtain data from a reflection, and will never modify a reflection.

Instrincs do not have to follow the rules of normal C++ functions, and __reflect does not. __reflect is "overloaded" based on its first argument -- the query -- with different return types.

As an example:

__reflect(query_is_class, refl); // returns `bool`
__reflect(query_get_type, refl); // returns `meta::info`

At the time of writing, all queries applicable to __reflect imply one additional argument, of meta::info type. This could change at some point in the future, resulting in a __reflect call that looks something like the following:

__reflect(query_is_foo, refl, ignore_bar);

reflect_mod

__reflect_mod is used for queries that modify a reflection in some way, and unlike __reflect has one return type, void.

At the time of writing, all queries applicable to __reflect_mod imply two additional arguments, one of meta::info type, and one which is dependent on the query provided.

As an example:

__reflect_mod(query_set_access, refl, (unsigned) 0); // takes a `meta::info`, and an `unsigned int` corresponding to an enumerator
__reflect_mod(query_set_add_constexpr, refl, true);  // takes a `meta::info`, and a `bool` flag

Similar to __reflect this may be expanded in the future, adding many additional arguments:

__reflect_mod(query_set_foo, refl, bar_1, bar_2, ..., bar_n);