veselink1 / refl-cpp

Static reflection for C++17 (compile-time enumeration, attributes, proxies, overloads, template functions, metaprogramming).
https://veselink1.github.io/refl-cpp/md__introduction.html
MIT License
1.06k stars 77 forks source link

Feature: Better base type support in type_descriptor #28

Closed veselink1 closed 4 years ago

veselink1 commented 4 years ago

Problem

The base types of a type can be specified with the base_types<Ts...> attribute (or via the bases<Ts...> template variable). To get a usable type_list one has to currently use a combination of get_attribute, decltype and the type_list member typedef of base_types. This is bad for usability.

Solution

Add better support for enumerating base types by exposing a typedef and a member type_list on type_descriptor, implemented on top of base_types. Expose these via type_descriptor and in the refl:: and refl::descriptor:: namespaces for similarity with member_list.

Possible interface

  1. Have base_types and indirect_base_types types, where the first variant is the directly declared bases, and the indirect variant is the full list of all direct and indirect bases.
  2. Have declared_base_types and base_types types, where the first variant is the directly declared bases, and the indirect variant is the full list of all direct and indirect bases. This matches better with the naming convention in #27 (Support inherited members) but might be less clear.