On Tuesday, 22 June 2021 21:52:16 CEST Jason Merrill wrote:
> For alias templates, you probably want the attribute only on the
> templated class, not on the instantiations.

Oh good point. My current patch does not allow the attribute on alias 
templates. Consider:

template <class T, class U>
  struct X {};

template <class T>
  using foo [[gnu::diagnose_as]] = X<T, int>;

I have no idea how this could work. I would have to set the attribute for an 
implicit partial specialization (not that I know of the existence of such a 
thing)? I.e. X<int, int> would have to be diagnosed as foo<int>, but X<int, 
float> would have to be diagnosed as X<int, float>, not foo.

So if anything it should only support alias templates if they are strictly 
"renaming" the type. I.e. their template parameters must match up exactly. Can 
I constrain the attribute like this? Or should we rely on developers to be 
reasonable and only use it for template aliases with matching template params?

-Matthias

-- 
──────────────────────────────────────────────────────────────────────────
 Dr. Matthias Kretz                           https://mattkretz.github.io
 GSI Helmholtz Centre for Heavy Ion Research               https://gsi.de
 std::experimental::simd              https://github.com/VcDevel/std-simd
──────────────────────────────────────────────────────────────────────────

Reply via email to