Hi David,

On Sat, Jan 15, 2022 at 8:45 PM David Rector via SG7 <sg7@lists.isocpp.org> wrote:

Now suppose a user decides they want to interface with reflection in an object-oriented style:
```
template<auto R>
struct DeclWrapper {
  auto nextDecl() { return DeclWrapper <decltype(std::meta::get_next_decl(R))>{}; }
  auto prevDecl() {…}
  auto getParent() { … }
  …
};

#include … // lots of stuff, big translation unit

int foo;
constexpr auto foorefl = DeclWrapper <decltype(^foo)>()>();
```

What happens when `foorefl` is instantiated?  

First each member of DeclWrapper<decltype(^foo)> must be instantiated, which means we have to instantiate each return type, each of which is a DeclWrapper, which itself has to be instantiated, …

The chain reaction results in instantiations of DeclWrappers for *every single declaration in the translation unit*.

I have actually done something like that here:
https://github.com/matus-chochlik/mirror/blob/develop/include/mirror/metadata.hpp
and
https://github.com/matus-chochlik/mirror/blob/develop/include/mirror/registry.hpp

for debugging, in order to have a way to easily force the extraction of all metadata and also to see the performance of such "chain reaction".

--Matus