Is TemplatePack<>...[I] allowed in C++26

110 views Asked by At

Pack indexing was introduced in C++26 and I was hoping for this feature to have a significant impact on metaprogramming stuff, especially for indexing packs which would otherwise require workarounds.

Since the syntax for pack indexing specifier is:

typedef-name ... [ expression ] 
  • where typedef-name is either identifier or simple-template-id

With the information above, does it allow to have like:

template <typename>
using apply_t = bool;

// #1
template <typename... Args>
using A = apply_t<Args>...[0];
// can be reworked with: apply_t<Args...[0]>

// #2
template <template <typename...> typename... Temps>
using B = Temps<>...[0]
// no other way other than this because 'Temps...[0]<>' is not allowed yet (?)
1

There are 1 answers

0
Davis Herring On BEST ANSWER

No: while typedef-name includes simple-template-id as a grammar production, in this context it is required ([dcl.type.pack.index]/1) to name a pack (and Temps<> is not itself a pack).

Note that the proposal discusses indexing into template template parameter packs (and even new kinds of packs) as a future extension.