Many tasks require rich meta-information(more than can give typeid). For example for build SQL-queries from struct we need names of fields:
struct person {string name; int salary} -> SELECT name, salary FROM person
or create table or interact with script or serialization or ...
So we need something like person::meta_info where meta_info is a struct with this information we need. But similar information we need from functions or enums that dont have operator "::" and C++ do not produce meta information for all types.
My proposal is to introduce attribute [[meta]]:
struct [[meta]] person {string name; int salary};
this code forces compiler to create "meta" template specialization
template<>
class meta<person> {
fieldinfo[] fields = { {name="name", type="std::string", shift=0, size=28}, ... } // array of field info structures
methodinfo[] = {} // array of method info structures
size_t obj_size = 32;//byte
}
or for function:
int main [[meta]] (char** argc, int argv) {...}
template specialization
template<>
class meta<main> {
arginfo[] args = { {name="name", type="char**"}, ... } // array of arg info structures
return_type = ....
name = "main"
....
}