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.05k stars 76 forks source link

Is it possible to get at nested member objects ? #41

Closed lenkite closed 2 years ago

lenkite commented 3 years ago

Thinking of writing a template engine (moustache) that can interpolate struct values into templates. However, it would be necessary to get at the values of nested member objects by name. Is it possible to do this using refl-cpp ? Basically to permit something like {{p.addr.city}}

    struct address {
        std::string city;
    };

    struct person {
        address addr;
    };
ccvca commented 3 years ago

If both, person and address, are reflectable, it's possible using recursion. (Call reflect on p and look for addr, then reflect addr and look for city).