bloomberg / clang-p2996

Experimental clang support for WG21 P2996 (Reflection).
https://github.com/bloomberg/clang-p2996/tree/p2996/P2996.md
52 stars 8 forks source link

Special handling of splicers as template arguments #8

Closed katzdm closed 5 months ago

katzdm commented 6 months ago

Although not yet documented by P2996, the intent is to follow the example of P1240 and make code like

template <std::meta::info... Rs>
void fn() {
  Cls<[:Rs:]...> cls;
}

work correctly, regardless of the kinds of entities reflected by Rs.... That is, splicers are treated specially when used as template arguments, and whereas a reflection of a type might ordinarily require a leading typename (e.g., typename [:R:]), no such qualifier is needed in the case of using a splicer as a template argument. This behavior would allow reflections to be used in situations similar to proposed "universal template parameters."

If I understand correctly, Lock3 implemented this using so-called mystery template arguments. We will probably similarly need to add a new kind of template argument, though I might prefer the name IndeterminateSplice rather than Mystery.