bloomberg / clang-p2996

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

Explicitly disallow concept splicers in template parameter declarations #34

Open katzdm opened 4 months ago

katzdm commented 4 months ago

Given the following:

template <std::meta::info R>
struct Outer {
  template <template [:R:] Param>
  struct Inner { /* ... */ };
};

It's not possible to tell at parse time whether Param is a non-type parameter of deduced type (i.e., if R reflects a class template) or if it's a type parameter (i.e., if R reflects a concept). The most obvious way to disambiguate this would be to introduce a "concept splicer" syntax (i.e., concept [:R:]), but we would prefer to add this in a later paper, and only if its absence is felt by users.

We're instead intending to disallow concept splicers in template parameter declarations. Note that this is easily worked around using requires clauses:

template <std::meta::info R>
struct Outer {
  template <typename T> requires template [:R:]<T>
  struct Inner { /* ... */ }
};